perl is too powerful to loop through a log file counting up instances of different ip addresses. just use something like this.
#!/usr/bin/perl
$log = "1.1.1.1 2.2.2.2 3.3.3.3 2.2.2.2 1.1.1.1 1.1.1.1";
while ($log =~ m/(\d\.\d\.\d\.\d)/g)
{
$ip = $1;
$count = ($log =~ s/$1/$1/g);
print "$ip $count\n";
}