while(<>) {
  chomp;
  next if /gperiodic\.seul\.org/;
  $_ = $_ eq '-' ? 'direct reference' : $_;
  s/\?.*$//;
  $r{$_}++;
}

foreach $url (keys(%r)) {
  $count{sprintf("%010d",$r{$url}) . ':' . $url} = 1;
}

print "Referals by count:\n";
foreach $key (reverse(sort(keys(%count)))) {
  $key =~ /^([^:]+):(.*)$/;
  ($count,$url)  = ($1,$2);
  $count += 0;
  printf("% 10s   <a href=\"$url\">%s</a>\n", $count, $url);
}

