in reply to Re: How do I check to see if a value in a hash is equal to something?
in thread How do I check to see if a value in a hash is equal to something?
Another way, of you are only interested in knowing if the value is in the hash, without knowing the key, could be:Rather than using a regular expression, just use an ordinary expression:This is not particularly space efficient if the hash is large. See also the second solution suggested in the FAQ mentioned above.$is_in_hash=grep /^Superman$/,values(%hash);
$is_in_hash = 0 < grep $_ eq "Superman", values %hash;
-- Randal L. Schwartz, Perl hacker
|
|---|