While that's very easy, it's not as fast as using a comparison operator such as 'eq' or '=='. However using these often leads to redundant and cumbersome looking code:
have you met my friend,
grep?
my @values= qw(foo bar baz bax);
my $test = "foo";
print "woo\n" if (grep {$_ eq $test}@values) ;
This is probably not the hottest use for
grep if you've got a long list of values, since it'll build an array of values matching the test only to use the result in a scalar fashion. It'd be handy if you could
last in a
grep in this particular instance.
You could produce the same behavior in a for loop quite easily that would exit on the first found value.