Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Getting keys of a hash element

by Trinary (Pilgrim)
on Jan 25, 2001 at 00:28 UTC ( [id://54114]=note: print w/replies, xml ) Need Help??


in reply to Getting keys of a hash element

Getting keys of a hash _element_ or getting keys of a hash? The latter would imply that the hash values are references to more hashes, which is very different. Example of the simple case:

foreach $key (sort(keys(%hash))) { print "Key = $key, value= $hash{$key}\n"; }

The whole reference can o' worms looks somethin like this:

foreach $key (sort(keys(%hash))) { print join(/ /,keys(%{$hash{$key}}),"\n"; }
There's probably about a million typos in there, but someone will correct me. =) That'll print out a line with the keys contained in the hash referred to by the values of %hash. Not sure if this is what you want, I'm guessing the first solution is closer to what you mean...

enjoy

Trinary

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-20 11:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found