for my $ip ( keys %conn ) { for my $port ( keys $conn{$ip} ) { if ( $conn{$ip}{$port} > $max_conns ) { printf "%-15s connected to TCP port %5d %9d times\n", $ip, $port, $conn{$ip}{$port}; } } }