use strict;
use warnings;

my $file = $ARGV[0];

open (FH, "<$file");
my %ip_stat;
while (my $line = <FH>) {
#131.130.102.51 - - [08/Jul/2005:20:10:34 +0200] "GET / HTTP/1.1" 200 11660
  $line =~ /^(.*?) /;
  $ip_stat{$1}++;  
#  if (exists $ip_stat{$1}) {
#    $ip_stat{$1} = $ip_stat{$1} + 1;
#  else {
#    $ip_stat{$1} = 1;
#  }
}

my @ip_sort = sort 
    {$ip_stat{$b} <=> $ip_stat{$a}}
    keys %ip_stat;

my $i;
foreach (@ip_sort) {
  last if $i++>15;
  printf "%02d: %-17s: %5d\n", 
     $i, $_, $ip_stat{$_};  
  }

#foreach my $ip (keys %ip_stat) {
#   printf "%-17s: %s\n", 
#           $ip, $ip_stat{$ip};
#}