Bug#613766: hardwired feature numbers in man page
jidanni at jidanni.org
jidanni at jidanni.org
Thu Feb 17 02:28:58 UTC 2011
Package: perl-doc
Version: 5.10.1-17
Severity: wishlist
File: /usr/share/man/man1/perlsyn.1.gz
First you say
use feature "switch";
then you say
use feature ":5.10";
Shouldn't both be
use feature "switch";
?
Switch statements
Starting from Perl 5.10, you can say
use feature "switch";
which enables a switch feature that is closely based on the Perl 6 proposal.
The keywords "given" and "when" are analogous to "switch" and "case" in other languages, so the code above could be
written as
given($_) {
when (/^abc/) { $abc = 1; }
when (/^def/) { $def = 1; }
when (/^xyz/) { $xyz = 1; }
default { $nothing = 1; }
}
This construct is very flexible and powerful. For example:
use feature ":5.10";
given($foo) {
when (undef) {
More information about the Perl-maintainers
mailing list