NAME
Geo::IP::PurePerl - Look up country by IP Address
SYNOPSIS
use Geo::IP::PurePerl;
my $gi = Geo::IP::PurePerl->new(GEOIP_STANDARD);
# look up IP address '65.15.30.247'
my $country = $gi->country_code_by_addr('65.15.30.247');
$country = $gi->country_code_by_name('yahoo.com');
# $country is equal to "US"
DESCRIPTION
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.
Free monthly updates to the database are available from http://www.maxmind.com/download/geoip/database/
CLASS METHODS
- $gi = Geo::IP->new( [$flags] );
-
Constructs a new Geo::IP object with the default database located inside your system's datadir, typically /usr/local/share/GeoIP/GeoIP.dat.
Flags can be set to either GEOIP_STANDARD, or for faster performance (at a cost of using more memory), GEOIP_MEMORY_CACHE. The default flag is GEOIP_STANDARD (uses less memory, but runs slower).
- $gi = Geo::IP->new( $database_filename );
-
Calling the
new
constructor in this fashion was was deprecated after version 0.26 in order to make the XS and pure perl interfaces more similar. Use theopen
constructor (below) if you need to specify a path. Eventually, this means of callingnew
will no longer be supported.Flags can be set to either GEOIP_STANDARD, or for faster performance (at a cost of using more memory), GEOIP_MEMORY_CACHE.
- $gi = Geo::IP->open( $database_filename, [$flags] );
-
Constructs a new Geo::IP object with the database located at
$database_filename
. The default flag is GEOIP_STANDARD (uses less memory, but runs slower).The database is available for free, updated monthly:
http://www.maxmind.com/download/geoip/database/
This free database is similar to the database contained in IP::Country, as well as many paid databases. It uses ARIN, RIPE, APNIC, and LACNIC whois to obtain the IP->Country mappings.
If you require greater accuracy, MaxMind offers a Premium database on a paid subscription basis.
OBJECT METHODS
- $code = $gi->country_code_by_addr( $ipaddr );
-
Returns the ISO 3166 country code for an IP address.
- $code = $gi->country_code_by_name( $ipname );
-
Returns the ISO 3166 country code for a hostname.
- $code = $gi->country_code3_by_addr( $ipaddr );
-
Returns the 3 letter country code for an IP address.
- $code = $gi->country_code3_by_name( $ipname );
-
Returns the 3 letter country code for a hostname.
- $name = $gi->country_name_by_addr( $ipaddr );
-
Returns the full country name for an IP address.
- $name = $gi->country_name_by_name( $ipname );
-
Returns the full country name for a hostname.
VERSION
1.10
AUTHOR
Copyright (c) 2002 MaxMind.com
All rights reserved. This package is free software; it is licensed under the GPL.