Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 cooling their heels in the Monastery: (8)
As of 2014-12-21 06:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (104 votes), past polls