$VAR1 = { '1.2.3.4' => { '27029' => 5, '20617' => 1 }, '1.2.3.5' => { '51509' => 1, '17427' => 1, '63961' => 7, '22331' => 1, '20780' => 7 }, '1.2.3.6' => { '1500' => 3 }, }; #### 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}; } } } #### 1.2.3.5 connected to TCP port 20780 7 times 1.2.3.4 connected to TCP port 27029 5 times 1.2.3.6 connected to TCP port 1500 3 times ...