#!/usr/bin/perl
use strict; use warnings;
use Geo::IP;
my ($ip) = @ARGV;
$ip ||= `myip | tee /dev/stderr`;
chomp $ip;
my $gi = Geo::IP->open("/usr/share/GeoIP/GeoIPCity.dat", GEOIP_STANDARD); 
my $record = $gi->record_by_addr($ip);
my $country = $record->country_code || '';
my $state = $record->region || '';
my $city = $record->city || '';
print "$country/$state/$city\n";
