Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
No such thing as a small change
 
PerlMonks  

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

by moritz (Cardinal)
on Aug 27, 2012 at 09:30 UTC ( #989951=note: print w/ replies, xml ) Need Help??


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

If you have a non-ancient version of Perl 5, this should work:

use 5.010; foreach (@array) { when (/linux/) { say "This is linux VM" } when (/Windows/) { say "This is Windows VM" } default { say "I have no idea what it is" } }


Comment on Re: Short and easy way to write if...elsif syntax
Download Code
Re^2: Short and easy way to write if...elsif syntax
by slayedbylucifer (Scribe) on Aug 27, 2012 at 09:46 UTC
    I wasn't aware of the "say" function. thanks for the suggestion and also thanks for the perl6 link that you have provided at the bottom of your response..

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-04-20 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls