Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Short and easy way to write if...elsif syntax

by LanX (Canon)
on Aug 28, 2012 at 08:58 UTC ( #990181=note: print w/ replies, xml ) Need Help??


in reply to Short and easy way to write if...elsif syntax

no need to repeat $_ =~ and just add next to avoid fall thru.

for ($given){ print "\nFOR($_):"; if (/abc/) { print "abc"} if (/def/) { print "def" ;next} if (/xyz/) { print "xyz" ;next} print "default"; }

more examples at Understanding the benefit of Given/When ...

Cheers Rolf


Comment on Re: Short and easy way to write if...elsif syntax
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990181]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2015-07-29 03:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls