Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: multipart key in hash, i'm confused

by tadman (Prior)
on Jan 19, 2004 at 20:28 UTC ( [id://322421]=note: print w/replies, xml ) Need Help??


in reply to multipart key in hash, i'm confused

If you have a hash of hashes (HoH), such as you have here, then you need to recurse through each level accordingly. The comma separator won't cut it. Here's a quick reference:
foreach my $key (keys %hash) { foreach my $subkey (keys %{$hash{$key}}) { print "$key,$subkey => $hash{$key}{$subkey}\n"; } }
This presumes you have a pure HoH structure, which is a fairly safe assumption if you've created it yourself. Note that in the second foreach you're casting the hash entry $hash{$key} as a hash itself so you can access the keys and iterate through this second layer.

Log In?
Username:
Password:

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

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

    No recent polls found