Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hello
I am porting a very simple script from Python to Perl using the GeoIP2. Module and database (GeoLite2-Country.mmdb) are correctly installed. But how do I get the country name starting from an IP? In Python is as simple as
response = reader.city('128.101.101.101') response.country.name
My Perl code
use GeoIP2::Database::Reader; my $ip = ('128.101.101.101'); my $reader = GeoIP2::Database::Reader->new(file => 'GeoLite2-Country.m +mdb'); my $record = $reader->country($ip);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: GeoLite2 get country name from IP
by pryrt (Abbot) on Apr 29, 2019 at 14:00 UTC | |
by Anonymous Monk on Apr 29, 2019 at 14:36 UTC |