Damian's Switch.pm relies on source filtering, which means that unless it can parse Perl perfectly (ha ha!), you'll get bugs in portions of code that having nothing to do with switches just because you included use Switch; in your code. So it shouldn't be used in any practical code.
One of the advantages of a C-style switch is that it gives you O(1) efficiency in going through the cases, whereas all Perl idioms for emulating it have a O(n) worst case (or all cases, if you don't include a last to break the switch. This was discussed at Re: Perl Idioms Explained: && and || "Short Circuit" operators.
Note that neither Switch.pm nor Perl6 switches offer O(1) efficiency, since they can't be implemented using jump tables like C switches are. For that, you need to use a dispatch table using hashes holding references to subroutines (super search for "dispatch table" should give interesting results).
----
: () { :|:& };:
Note: All code is untested, unless otherwise stated
In reply to Re^6: No braces
by hardburn
in thread No braces
by jacques
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |