The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

IP::Country::NetOp - NetOp IP geolocation via DNS

SYNOPSIS

  use IP::Country::NetOp;
  my $reg = IP::Country::NetOp->new();
  print $reg->inet_atocc('212.67.197.128')   ."\n";
  print $reg->inet_atocc('www.slashdot.org') ."\n";

DESCRIPTION

Finding the home country of a client using only the IP address can be difficult. Looking up the domain name associated with that address can provide some help, but many IP address are not reverse mapped to any useful domain, and the most common domain (.com) offers no help when looking for country.

This module queries a netop.org server to find the correct country code.

CONSTRUCTOR

The constructor takes no arguments.

  use IP::Country::NetOp;
  my $reg = IP::Country::NetOp->new();

OBJECT METHODS

All object methods are designed to be used in an object-oriented fashion.

  $result = $object->foo_method($bar,$baz);

Using the module in a procedural fashion (without the arrow syntax) won't work.

$cc = $reg->inet_atocc(HOSTNAME)

Takes a string giving the name of a host, and translates that to an two-letter country code. Takes arguments of both the 'rtfm.mit.edu' type and '18.181.0.24'. If the host name cannot be resolved, returns undef. If the resolved IP address is not contained within the database, returns undef. For multi-homed hosts (hosts with more than one address), the first address found is returned.

$cc = $reg->inet_ntocc(IP_ADDRESS)

Takes a string (an opaque string as returned by Socket::inet_aton()) and translates it into a two-letter country code. If the IP address is not contained within the database, returns undef.

BUGS/LIMITATIONS

Only works with IPv4 addresses and ASCII hostnames.

SEE ALSO

http://www.netop.org/geoip.html - NetOp: IP geolocation via DNS

IP::Country::Fast - uses local database for lookups.

COPYRIGHT

Copyright (C) 2006, Nigel Wetters Gourlay.

NO WARRANTY. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.