Use el módulo Switch (no es necesario en las versiones posteriores a la 5.10):
lhp@europa:~/projects/perl/src/perltesting$ cat switch.pl #!/usr/bin/perl -w use strict; use Perl6::Say; use Switch; my $val = <>; chomp($val); switch ($val) { case 1 { say "number 1" } case "a" { say "string a" } case [1..10,42] { say "number in list" } case /^\w+$/ { say "pattern" } else { say "previous case not true" } }Veamos algunas ejecuciones:
lhp@europa:~/projects/perl/src/perltesting$ ./switch.pl 5 number in list lhp@europa:~/projects/perl/src/perltesting$ ./switch.pl 12bc pattern lhp@europa:~/projects/perl/src/perltesting$ ./switch.pl .2. previous case not true
Casiano Rodríguez León