onlyIDleft has asked for the wisdom of the Perl Monks concerning the following question:
I need your help to extract hash keys for values stored in an array (or a scalar).
In my example the hash keeps changing in a loop and so does the the array )or scalar. For example, %hash={a=>2,b=>3,c=>3}, and @array=(3) or even $scalar=3 (since array is really one element, it can be a scalar as easily); I want the script to return either b or c as keys to the value of 3 (b OR c are equally acceptable answers, but NOT both)
I am a newbie to PERL programming, so I am familiar only with using keys, values and each for hashes, but I am not sure how to extract a key given the value in a separate scalar or array.
Thanks...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extract hash keys for values stoted in array
by BrowserUk (Patriarch) on May 01, 2011 at 10:42 UTC | |
by onlyIDleft (Scribe) on May 01, 2011 at 22:20 UTC | |
by BrowserUk (Patriarch) on May 02, 2011 at 00:01 UTC | |
by onlyIDleft (Scribe) on May 02, 2011 at 19:56 UTC | |
|
Re: Extract hash keys for values stoted in array
by AnomalousMonk (Archbishop) on May 01, 2011 at 12:53 UTC |