Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Comparing against multiple values

by AidanLee (Chaplain)
on Mar 18, 2002 at 23:07 UTC ( #152605=note: print w/replies, xml ) Need Help??


in reply to Comparing against multiple values

PrimeLord's hash suggestion is quite good. I'd suggest also maybe a for loop as something more traditional:

for( qw( foo bar baz ) ){ print "yep" and last if $test eq $_; }
or all on one line:
print "yep" and last if $test eq $_ for( qw( foo bar baz ) );
if it'll be a more complex action down the line, you can "do":
do { print "yep"; last; } if $test eq $_ for( qw( foo bar baz ) );

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://152605]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2018-06-18 20:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (110 votes). Check out past polls.

    Notices?