in reply to Pingu can't sort a hash
sub sort_ips() { my %counts; my $hash_ref = shift; print "Subnet\t\tCount\n"; foreach my $ip(keys(%$hash_ref)) { my $subnet = pack 'C3', split /\./, $ip; $counts{$subnet}++; } foreach my $subnet(sort keys(%counts)) { print join '.', unpack 'C3', $subnet; print ":\t$counts{$subnet}"; print "\n"; } print "\n"; }
|
|---|