in reply to Re: Comparing against multiple values
in thread Comparing against multiple values
Maybe you want to score points for obfuscation:
A dirty, and almost as quick way is:if ({map{$_=>1}($bar,$baz,$boo)}->{$foo}) { print "Yes!\n"; }
If you are comparing frequently, you might want to have a persistent hash which you can refer to on a regular basis. Why create it every time if it is the same?if (grep{$_ eq $foo} $bar, $baz, $boo) # ...
In Section
Seekers of Perl Wisdom