Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://152605]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2022-05-16 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (63 votes). Check out past polls.

    Notices?