Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Getting Keys of Hash from Values

by ikegami (Patriarch)
on Nov 16, 2005 at 21:07 UTC ( #509194=note: print w/replies, xml ) Need Help??


in reply to Getting Keys of Hash from Values

Like this?
my %hash = ( apple => 'red', banana => 'yellow', orange => 'orange', lemon => 'yellow', ); my $value = 'yellow'; my @matching_keys = grep { $hash{$_} eq $value } keys %hash; print("$_\n") foreach @matching_keys;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2022-05-26 18:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (93 votes). Check out past polls.

    Notices?