IP::Cou...MaxMind(3)
okay bestie, welcome to IP::Cou...MaxMind(3) from the User Contributed Perl Documentation manual π this page is all about looking up a country by IP address, and yes itβs giving old-school Perl but make it cute.
β¨ NAME β¨
IP::Country::MaxMindβ Look up country by IP Address π
π¦ SYNOPSIS π¦
use IP::Country::MaxMind;
my $gi = IP::Country::MaxMind->new(GEOIP_STANDARD);
# look up IP address '65.15.30.247'
# returns undef if country is unallocated, or not defined in our database
my $cc1 = $gi->inet_atocc('65.15.30.247');
my $cc2 = $gi->inet_atocc('yahoo.com');
πΈ DESCRIPTION πΈ
This module adapts the Geo::IP module so it uses the same interface as the IP::Country modules π«Ά which means you can easily switch between the two underlying databases without your whole life falling apart. iconic, honestly.
πΎ DATABASE UPDATES πΎ
Free monthly updates to the database are available from:
http://www.maxmind.com/download/geoip/database/
If you require greater accuracy, MaxMind offers a Premium database on a paid subscription basis πΈ
The author of this module is in no way associated with MaxMind. no cap, just making that clear π«‘
π CLASS METHODS π
π
$gi = IP::Country::MaxMind->new( $flags );
Constructs a new IP::Country::MaxMind 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 the cost of using more memory β GEOIP_MEMORY_CACHE π₯ When using memory cache you can force a reload if the file is updated by setting GEOIP_CHECK_CACHE.
So the flag vibe check is:
GEOIP_STANDARDβ the standard mode.GEOIP_MEMORY_CACHEβ faster performance, but it uses more memory.GEOIP_CHECK_CACHEβ when using memory cache, force a reload if the file is updated.
π
$gi = IP::Country::MaxMind->open( $database_filename, $flags );
Constructs a new Geo::IP object with the database located at $database_filename ποΈ yes bestie, Geo::IP is exactly what it says.
π 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. periodt.
$cc = $gi->inet_atocc(HOSTNAME)β Takes a string giving the name of a host, and translates that into a 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, returnsundef. If the resolved IP address is not contained within the database, returnsundef.$cc = $gi->inet_ntocc(IP_ADDRESS)β Takes a string (an opaque string as returned bySocket::inet_aton()) and translates it into a two-letter country code. If the IP address is not contained within the database, returnsundefπ$cc = $gi->db_time()β Returns zero. For compatibility only π«Ά
π COPYRIGHT π
Copyright (C) 2002,2003 Nigel Wetters Gourlay. All Rights Reserved.
NO WARRANTY. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and thatβs the whole manual page, bestie π«Ά β IP::Cou...MaxMind(3) came from perl v5.42.0, dated 2015-04-14. slay β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-IP-Country 2.28-bp160.1.12 Β· (GPL-1.0+ or Artistic-1.0) and SUSE-Redistributable-Content
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms