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" } }
In reply to Re: Short and easy way to write if...elsif syntax
by moritz
in thread Short and easy way to write if...elsif syntax
by slayedbylucifer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |