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 reply to Re^2: Comparing against multiple values
by tadman
in thread Comparing against multiple values
by doran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |