in reply to Comparing against multiple values
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?
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.my @values= qw(foo bar baz bax); my $test = "foo"; print "woo\n" if (grep {$_ eq $test}@values) ;
|
|---|