Let\'s say I have this
#!/usr/bin/perl %x = (\'a\' => 1, \'b\' => 2, \'c\' => 3);
and I would like to know if the value 2 is a ha
grep and values
my %x = ('a' => 1, 'b' => 2, 'c' => 3); if (grep { $_ == 2 } values %x ) { print "2 is in hash\n"; } else { print "2 is not in hash\n"; }
See also: perldoc -q hash
perldoc -q hash