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("18.104.22.168"); print "The location of 22.214.171.124 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.
DATAFILEis the name of the QQWry datafile to which the queries use.
DATAFILEis optional. This file is used when initializing a new IP::Location object.
CHAR_SETis optional. If
CHAR_SETis not given, then the object will use GBK as the default character set. You can use the
char_setmethod 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 http://lumaqq.linuxsir.org/article/qqwry_format_detail.html.
The latest version of QQWry datafile can be found at http://www.cz88.net/fox/
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.