Search notes:

Perl module Geo::IP

Apparently, the module needs /usr/local/share/GeoIP/GeoIp.dat.
#!/usr/bin/perl
use warnings;
use strict;

use Geo::IP;

my $ipnr = shift or die;

my $geo_ip = Geo::IP->new(                                         GEOIP_STANDARD) or die;
my $city   = Geo::IP->open('/usr/local/share/GeoIP/GeoIPCity.dat', GEOIP_STANDARD) or die;

printf "%s (%s %s)\n",
  $geo_ip->country_name_by_addr ($ipnr),  # full country name
  $geo_ip->country_code_by_addr ($ipnr),  # ISO 3166 country code
  $geo_ip->country_code3_by_addr($ipnr);  #


my $cr = $city->record_by_addr($ipnr);

# my $rec = $geo_ip->record_by_addr($ipnr);
#
# print join "\n", keys %{$rec};
#
# 2018-03-10 cr does not seem to be a hash reference anymore.
#
printf "City:      %s %s\n"     , $cr->city, $cr->postal_code;
printf "Region:    %s %s\n"     , $cr->region, $cr->region_name;
printf "Country:   %s (%s %s)\n", $cr->country_name, $cr->country_code, $cr->country_code3;
printf "Continent: %s\n"        , $cr->continent_code;
printf "lon/lat:   %s / %s\n"   , $cr->longitude, $cr->latitude;
printf "Metrocde:  %s\n"        , $cr->metro_code;
Github repository PerlModules, path: /Geo/IP/script.pl

See also

GeoIP2::WebService::Client, Geo::Coder::HostIP
The github repository for Geo::IP.
Perl modules for geographic calculations
Perl modules

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1741108787, '18.191.18.220', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/modules/Geo/IP/index(80): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78