It wasn't my idea. I took it from "Programming Perl" by Wall, Christiansen & Schwartz. Chapter 2: You might think it odd to write a loop over a single value, but a common idiom for a switch statement is to use foreach's aliasing capability to make a temporary assignment to $_ for convenient matching.
In reply to Re^6: Avoiding if/else knots II
by Skeeve
in thread Avoiding if/else knots II
by loris
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |