The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

SYNOPSIS

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

DESCRIPTION

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.

CONSTRUCTOR

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.

METHODS

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.

version

Return the version of the datafile and the module.

info

More verbose information about the datafile.

SEE ALSO

The format of the QQWry datafile can be referred at http://lumaqq.linuxsir.org/article/qqwry_format_detail.html.

The latest version of QQWry datafile can be found at http://www.cz88.net/fox/

AUTHOR

michael.wang, <ylzcylx@gmail.com>

COPYRIGHT AND LICENSE

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.