- NAME
- SYNOPSIS
- DESCRIPTION
- FUNCTIONS

- ip_to_country
- lookup_possible

- MODULES
- SEE ALSO
- COPYRIGHT
- VERSION

# NAME

GT::IPCountry - Attempts to look up an IP's country using a variety of common CPAN modules.

# SYNOPSIS

        use GT::IPCountry;

        my $country = ip_to_country("209.139.239.160");

        my ($country, $lookup_okay) = ip_to_country("209.139.239.160");

        my $can_lookup = GT::IPCountry::lookup_possible();

# DESCRIPTION

This module takes an IP address and returns the country name the IP is reserved for. This module itself does no actual lookup, but is simply a wrapper around serveral CPAN modules. If none of the modules are available, it simply returns the value `undef`.

# FUNCTIONS

## ip_to_country

This method takes a country name and returns two elements: the country name, and a true/false value indicating whether one of the lookup modules was available. In scalar context just the country name is returned. A country name of `undef` indicates that either the IP wasn't found, or no lookup module was available.

`ip_to_country` is exported by default.

## lookup_possible

This method returns a true/false value indicating whether or not an IP -> Country lookup can be done. It corresponds directly to the second return value of `ip_to_country`.

# MODULES

GT::IPCountry attempts to use the following modules, in order, to perform a country lookup:

Geo::IP

  Uses Geo::IP for the lookup.

IP::Country

  Uses IP::Country for the lookup. Note that because IP::Country only returns a country code, this module will attempt to use Geography::Countries to determine the country name. If Geography::Countries isn't installed, you'll just get a country code.

Geo::IPfree

  Uses Geo::IPfree for the lookup.

# SEE ALSO

the Geo::IP manpage

the Geo::IPfree manpage

the IP::Country manpage

# COPYRIGHT

Copyright (c) 2006 Gossamer Threads Inc. All Rights Reserved. http://www.gossamer-threads.com/

# VERSION

Revision: $Id: IPCountry.pm,v 1.1 2006/01/31 00:45:04 jagerman Exp $