Why not use a list operator in this case? grep comes to mind, but especially first that is in the List::Util module (part of the Perl 5.8 distribution if memory serves).
use List::Util qw( first ); if (defined(first {'abc' eq $_} qw( abc def ghi ))) { print "found 'abc'\n"; }
Hope this helps, -gjb-
Update: Thanks to diotalevi for pointing out issues with my solution. I agree with both: I suggested first for exactly his objection to grep and I modified the original code by adding defined to resolve his objection to find.
In reply to Re: matching strings...
by gjb
in thread matching strings...
by powerhouse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |