my $remote_host = gethostbyaddr(inet_aton ($ip_addr),AF_INET); # get www.xxx.xxx.uk my %CountryCode = { 'com','Comercial', 'uk','The United Kingdom', } # a hash of country name my $CountryName; my @CCode = split /./, $remote_host; # split every portion my $Country = $CCode[-1]; # get the last foreach $key (keys %CountryCode) { if ($Country == $key){ #get the key of country name $CountryName = $CountryCode($key); #assign the key value to a variable } }