A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label switch. Show all posts
Showing posts with label switch. Show all posts

Switch for Perl done right

Instead of the horribly flaky 'Switch' module, from Perl 5.10 you can now do:

use feature "switch";

given($_) {
    when (/^abc/) { $abc = 1; }
    default { $nothing = 1; }
}
 
See http://perldoc.perl.org/perlsyn.html#Switch-statements