Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: how do I iterate over a hash of hashes?

by kutsu (Priest)
on Apr 22, 2005 at 18:28 UTC ( [id://450525]=note: print w/replies, xml ) Need Help??


in reply to how do I iterate over a hash of hashes?

you have to loop over the keys of both hashes (perldsc has more info), like this:

for my $first_key ( keys %HoH ) { print "$first_key: \n"; for my $second_key ( keys %{ $HoH{$first_key} } ) { print "$second_key=$HoH{$first_key}{$second_key} "; } print "\n"; }

Update: Fixed typo in second for loop.

"Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://450525]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found