http://www.perlmonks.org?node_id=1041982


in reply to For loop: Hash

No objection to what hdb said above.
If you have to use the exact data structure you presented above, this might be the way to go:

for my $i ( sort keys %{$router_href} ) { for my $j ( sort keys %{$router_href->{$i}->{bgpPeer}} ) { print "($i:$j) " , $router_href->{$i}{bgpPeer}{$j}{Name} , ":\t" , $router_href->{$i}{bgpPeer}{$j}{prefixList} , "\n" } }

Cheers, Sören

(hooked on the Perl Programming language)