printf "%-15s connected to TCP port %5d %9d times\n", @$_ for sort { $b->[2] <=> $a->[2] } grep { $_->[2] > $max_conns } map { my $ip = $_; map { [ $ip, $_, $conn{$ip}{$_} ] } keys %{$conn{$ip}} } keys %conn;