See the docs for Switch statements.use strict; use feature qw(switch say); use warnings; foreach my $str (qw/fookey1 barkey2 bazkey3/) { given ($str) { when (/key1/) { say 'matched key1'; } when (/key2/) { say 'matched key2'; } when (/key3/) { say 'matched key3'; } } }
In reply to Re: if or switch?
by Arunbear
in thread if or switch?
by gw1500se
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |