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" } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Short and easy way to write if...elsif syntax
by slayedbylucifer (Scribe) on Aug 27, 2012 at 09:46 UTC |