use Socket qw( inet_aton ); while (<>) { my $host = extract_host($_); print(unpack('H8', inet_aton($host)), $_); } #### my $last; my $count; while (<>) { my $ip = extract_ip($_); if (defined($last) && $last ne $ip) { print("$last: $count\n"); $count = 0; } $last = $ip; ++$count; } if (defined($last)) { print("$last: $count\n"); }