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

Re: Getting Keys of Hash from Values

by duff (Parson)
on Nov 16, 2005 at 21:10 UTC ( [id://509195]=note: print w/replies, xml ) Need Help??


in reply to Getting Keys of Hash from Values

I think you want something like this:

my @keys = grep { $hash{$_} eq $value } keys %hash;
That iterates over all of the keys of %hash and if any value in the hash is equal to the value we're interested in, then the expression evaluates to a true value and so the key gets put into the @keys array.

Log In?
Username:
Password:

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

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

    No recent polls found