GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Geo::IP::PurePerl(3) User Contributed Perl Documentation Geo::IP::PurePerl(3)

Geo::IP::PurePerl - Look up country by IP Address

This module has been deprecated, please use Geo::IP instead. Geo::IP::PurePerl has been merged with Geo::IP.

  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"

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.

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

$gi = Geo::IP::PurePerl->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::PurePerl->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::PurePerl->open( $database_filename, [$flags] );
Constructs a new Geo::IP::PurePerl object with the database located at $database_filename. The default flag is GEOIP_STANDARD (uses less memory, but runs slower).

$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.
$old_charset = $gi->set_charset( $charset );
Set the charset for the city name - defaults to GEOIP_CHARSET_ISO_8859_1. To set UTF8, pass GEOIP_CHARSET_UTF8 to set_charset.
$charset = $gi->charset;
Gets the currently used charset.
$netmask = $gi->last_netmask;
Gets netmask of network block from last lookup.
$gi->netmask(12);
Sets netmask for the last lookup
my ( $from, $to ) = $gi->range_by_ip('24.24.24.24');
Returns the start and end of the current network block. The method tries to join several continous netblocks.
@data = $gi->get_city_record( $addr );
 Returns a array filled with information about the city.

  my ($country_code,$country_code3,$country_name,$region,$city,$postal_code,$latitude,$longitude,$metro_code,$area_code ) = $gi->get_city_record($addr);
    
$href = get_city_record_as_hash( $addr );
 Returns a hashref filled with information about the city.

  my $href = $gi->get_city_record_as_hash($addr);
    

The hash include the following keys: country_code, country_code3, country_name, region, city, postal_code, latitude, longitude, metro_code, area_code

$gi->isp_by_addr($addr)
 Returns the isp name for an ipaddress
    
$gi->isp_by_name($name)
 Returns the isp name for a hostname
    
$gi->org_by_addr($addr)
 Returns the organisation name for an ipaddress
    
$gi->org_by_name($name)
 Returns the organisation name for a hostname
    

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

1.26

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.

Copyright (c) 2012 MaxMind Inc

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

2016-01-26 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.