diff options
author | Lukas Mai <l.mai@web.de> | 2016-01-06 00:35:24 +0100 |
---|---|---|
committer | Lukas Mai <l.mai@web.de> | 2016-01-06 00:40:52 +0100 |
commit | 015aa1a8bb85e915bcad7260c8d42e63732ebce5 (patch) | |
tree | dcb47b637590e2788fc05d181d5a0fa13bae7b14 /pod/perlsyn.pod | |
parent | 1ef95abd22cb7e7bc8dea64138acb366b461f657 (diff) | |
download | perl-015aa1a8bb85e915bcad7260c8d42e63732ebce5.tar.gz |
perlsyn: change = to == in conditional in do/while example
... also remove unused LOOP label from 'last' example, mention 'redo'
(works like 'next' in this case), add example that combines
'next'/'last' (and requires the label).
Diffstat (limited to 'pod/perlsyn.pod')
-rw-r--r-- | pod/perlsyn.pod | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod index 01425d261d..09cfd13b98 100644 --- a/pod/perlsyn.pod +++ b/pod/perlsyn.pod @@ -181,23 +181,35 @@ This is so that you can write loops like: See L<perlfunc/do>. Note also that the loop control statements described later will I<NOT> work in this construct, because modifiers don't take loop labels. Sorry. You can always put another block inside of it -(for C<next>) or around it (for C<last>) to do that sort of thing. -For C<next>, just double the braces: +(for C<next>/C<redo>) or around it (for C<last>) to do that sort of thing. X<next> X<last> X<redo> +For C<next> or C<redo>, just double the braces: + do {{ next if $x == $y; # do something here }} until $x++ > $z; -For C<last>, you have to be more elaborate: +For C<last>, you have to be more elaborate and put braces around it: X<last> + { + do { + last if $x == $y**2; + # do something here + } while $x++ <= $z; + } + +If you need both C<next> and C<last>, you have to do both and also use a +loop label: + LOOP: { - do { - last if $x = $y**2; - # do something here - } while $x++ <= $z; + do {{ + next if $x == $y; + last LOOP if $x == $y**2; + # do something here + }} until $x++ > $z; } B<NOTE:> The behaviour of a C<my>, C<state>, or |