foreach $entry (sort keys %{ $Stats{$TopPorts[$a]}{covert} }) { # my code to print out various HTML # elements is typically here }