Alternately if this is something you need to do often build an inverted hash with the keys and values switched.
my %hash_inverted; @hash_inverted{ values %hash } = keys %hash;
Just remember that this won't be automagically updated so if you update %hash you'll need to also update %hash_inverted (and/or wrap them both up in an object and let that keep things updated for you when you use its accessors).
Update: Good point below about duplicates, which also brings up the point that if your original hash has non-scalar values you may need something like Tie::RefHash for the inverted version.
In reply to Re^2: grep value in hash
by Fletch
in thread grep value in hash
by kanish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |