Geo::IP::PurePerl is a Perl module to lookup country by IP Address.
my $gi = Geo::IP::PurePerl->new(GEOIP_STANDARD);
# look up IP address '184.108.40.206'
my $country = $gi->country_code_by_addr('220.127.116.11');
$country = $gi->country_code_by_name('yahoo.com');
# $country is equal to "US"
This module uses a file based database. This database simply contains IP blocks as keys, and countries as values. This database is more complete and accurate than reverse DNS lookups.
This module can be used to automatically select the geographically closest mirror, to analyze your web server logs to determine the countries of your visiters, for credit card fraud detection, and for software export controls.