Dear all,
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...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.