After you will type at least use 5.010 you can use given statement. It allows you to use when inside it, but for/foreach also allows it. I would like to know why Perl has given when for can be used for this same thing (at least I think so).
For background, in this example, both code samples are equivalent.
for ($value) { when (1) { say "One!" } when (2) { say "Two!" } default { say "Something!" } }
given ($value) { when (1) { say "One!" } when (2) { say "Two!" } default { say "Something!" } }
In reply to given and for by GlitchMr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |