#!/usr/bin/perl # Where is the nationality of users? # Author: Ian Hickman my %total; my $country; while( ){ my @field=split; $_=$field[0]; if( !($_=~/^[\w\-]*\.[\w\-]*$/) ){ ($country)=/.*\.([\w\-]*\.[\w\-]*)/; } else { $country=$_; } if( !($country=~/\.uk$/) ){ $_=$country; ($country)=/[\w\-]*\.([\w\-]*)$/; } if( $country=~/\d+/ ){ $country="numeric" } if( !($country=~/./) ){ print STDERR "$field[0]\n"; } $total{$country}++; } foreach $country ( keys ( %total )){ print"$country\t$total{$country}\n"; }