GT::IPCountry - Attempts to look up an IP's country using a variety of common CPAN modules.
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();
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
.
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.
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
.
GT::IPCountry attempts to use the following modules, in order, to perform a country lookup:
Uses Geo::IP for the lookup.
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.
Uses Geo::IPfree for the lookup.
Copyright (c) 2006 Gossamer Threads Inc. All Rights Reserved. http://www.gossamer-threads.com/
Revision: $Id: IPCountry.pm,v 1.1 2006/01/31 00:45:04 jagerman Exp $