use CGI; use Geo::IP; my $cgi = CGI->new; my $geo = Geo::IP->new; my $ip_addr = gethostbyname( $cgi->remote_host ); my $country = $geo->country_code_by_addr( inet_ntoa( $ip_addr ) );