X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlsyn.pod;h=28bb824ada99bf497848e2193ec0fb33941d9a6f;hb=6e0733998eff7a098d2d21d5602f3eb2a7521e1f;hp=ec865103c55ae71e6c6556ec94b029d0564514f8;hpb=d6db67f2d91e588a13d4c1b90d1af1054faf4d41;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod index ec86510..28bb824 100644 --- a/pod/perlsyn.pod +++ b/pod/perlsyn.pod @@ -117,7 +117,7 @@ is treated as 0. =head2 Statement Modifiers X X X X X -X X X +X X X X Any simple statement may optionally be followed by a I modifier, just before the terminating semicolon (or block ending). The possible @@ -127,6 +127,8 @@ modifiers are: unless EXPR while EXPR until EXPR + when EXPR + for LIST foreach LIST The C following the modifier is referred to as the "condition". @@ -139,6 +141,22 @@ the condition is true (i.e., if the condition is false). print "Basset hounds got long ears" if length $ear >= 10; go_outside() and play() unless $is_raining; +C executes the statement I C<$_> smart matches C, and +then either Cs out if it's enclosed in a C scope or skips +to the C element when it lies directly inside a C loop. +See also L. + + given ($something) { + $abc = 1 when /^abc/; + $just_a = 1 when /^a/; + $other = 1; + } + + for (@names) { + admin($_) when [ qw/Alice Bob/ ]; + regular($_) when [ qw/Chris David Ellen/ ]; + } + The C modifier is an iterator: it executes the statement once for each item in the LIST (with C<$_> aliased to each item in turn). @@ -716,7 +734,8 @@ See L. The Perl 5 smart match and C/C constructs are not absolutely identical to their Perl 6 analogues. The most visible difference is that, in Perl 5, parentheses are required around -the argument to C and C. Parentheses in Perl 6 +the argument to C and C (except when this last +one is used as a statement modifier). Parentheses in Perl 6 are always optional in a control construct such as C, C, or C; they can't be made optional in Perl 5 without a great deal of potential confusion, because Perl 5