in reply to Re: grep value in hash
in thread grep value in hash

I can't see how scalar @art could ever return a negative number, so your >0 check is probably overkill.

print "found" if scalar @ary;

But, given that grep in scalar contents returns the number of matches, I'd probably skip the temporary value and use:

print "found" if grep { /one/ } values %hash;

Oh, and using a regex to match a fixed string is inefficient.

print "found" if grep { $_ eq 'one' } values %hash;

And we're pretty much back to my first solution :)

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg