Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Get the Key corresponding to any given value

by simmisam (Novice)
on Jan 17, 2014 at 06:54 UTC ( [id://1070902]=note: print w/replies, xml ) Need Help??


in reply to Get the Key corresponding to any given value

my ($key) = grep {$value ~~ $hash{$_}} keys %hash; print "Key = $key\n";

Replies are listed 'Best First'.
Re: Answer: Get the Key corresponding to any given value
by LanX (Saint) on Jan 20, 2014 at 12:50 UTC
    values are not necessarily unique so the left hand side should be a list.

    and using smart match doesn't make sense, better decide if == or eq are appropriate.

    simmisam did you notice that most of your recent answers in this category were rejected by QandAEditors b/c of poor quality?

    And (sadly) I have to say, I hope this one too!

    Maybe you should stop playing this game till you are more experienced?

    Cheers Rolf

    ( addicted to the Perl Programming Language)

      I'm actually OK with this one, but I would prefer that he would include an explanation of the value of his approach, i.e. describe the situations in which he thinks it could be useful.

      I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.
        > I'm actually OK with this one...

        Well a 90% copy from the second part of the first answer, just that everything changed is worse now.

        I can't see how readers may rather profit instead of being confused or mislead.

        Cheers Rolf

        ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2026-01-23 13:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (125 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.