[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#580059: ITP: libswitch-perl -- A switch statement for Perl



]] Dominic Hargreaves 

| Package: wnpp
| Severity: wishlist
| Owner: Dominic Hargreaves <dom@earth.li>
| 
| * Package name    : libswitch-perl
|   Version         : 2.16
|   Upstream Author : Damian Conway <damian@conway.org>
| * URL             : http://search.cpan.org/dist/Switch/
| * License         : Perl
|   Programming Lang: Perl
|   Description     : A switch statement for Perl
| 
| The Switch.pm module implements a generalized case mechanism that
| covers many possible combinations of switch and case values.

Why not just use feature.pm instead?

use feature qw(switch);
given ($foo) {
               when (1)          { say "\$foo == 1" }
               when ([2,3])      { say "\$foo == 2 || \$foo == 3" }
               when (/^a[bc]d$/) { say "\$foo eq 'abd' || \$foo eq 'acd'" }
               when ($_ > 100)   { say "\$foo > 100" }
               default           { say "None of the above" }
           }

this is part of 5.10.

-- 
Tollef Fog Heen
UNIX is user friendly, it's just picky about who its friends are



Reply to: