Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Comparing against multiple values

by AidanLee (Chaplain)
on Mar 18, 2002 at 23:07 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2024-04-23 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found