IP::Location - Perl extension for getting the location of an IP.


  no warnings;
  use IP::Location;
  my $QQWRY = IP::Location->new("qqwry.dat");
  my $location = $QQWRY->locate("");
  print "The location of is $location\n";


IP::Location is a perl extension for getting the location of an IP through datafile or the Internet. When it works in the local mode, it queries the local QQWry datafile, when it works in the network mode, it works as an interface to the online IP location database.


new ( [DATAFILE] [, CHAR_SET])

This is the constructor for a new IP::Location object. DATAFILE is the name of the QQWry datafile to which the queries use.

DATAFILE is optional. This file is used when initializing a new IP::Location object.

CHAR_SET is optional. If CHAR_SET is not given, then the object will use GBK as the default character set. You can use the char_set method to change its value.


init ( DATAFILE )

Initialize the new created IP::Location object with the given datafile.

locate ( IP_ADDRESS )

Returns the location of the given IP address.

char_set( [CHARACTER_SET] )

If the method is called without parameter, it returns the current character set the module uses. If the method is called with a CHARACTER_SET parameter, it will set the character set to the given value. The current supported character set is GBK and UTF-8. GBK is used as the default value.


Return the version of the datafile and the module.


More verbose information about the datafile.


The format of the QQWry datafile can be referred at

The latest version of QQWry datafile can be found at



Copyright (C) 2011 by Michael Wang (loveky)

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.