T.J. Mather > Geo-IP-PurePerl-1.19 > Geo::IP::PurePerl

Download:
Geo-IP-PurePerl-1.19.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 1.19   Source   Latest Release: Geo-IP-PurePerl-1.25

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 '24.24.24.24'
  my $country = $gi->country_code_by_addr('24.24.24.24');
  $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.

IP ADDRESS TO COUNTRY DATABASES ^

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 paid database on a paid subscription basis from http://www.maxmind.com/app/country

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 the open constructor (below) if you need to specify a path. Eventually, this means of calling new 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).

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.

$info = $gi->database_info;

Returns database string, includes version, date, build number and copyright notice.

MAILING LISTS AND CVS ^

Are available from SourceForge, see http://sourceforge.net/projects/geoip/

VERSION ^

1.19

SEE ALSO ^

Geo::IP - this now has the PurePerl code merged it, so it supports both XS and Pure Perl implementations. The XS implementation is a wrapper around the GeoIP C API, which is much faster than the Pure Perl API.

AUTHOR ^

Copyright (c) 2008 MaxMind Inc

All rights reserved. This package is free software; it is licensed under the GPL.

syntax highlighting: