diff options
author | Zefram <zefram@fysh.org> | 2017-11-29 19:27:49 +0000 |
---|---|---|
committer | Zefram <zefram@fysh.org> | 2017-11-29 19:27:49 +0000 |
commit | 619bbb9ab0f3cffda05f980b2ebb5bf660ad6962 (patch) | |
tree | cf70aae25e996d4bb11db230639148fc32ed0c61 /pod/perlsyn.pod | |
parent | df16d5564aa82a94953a0bccfc9917bc140ead02 (diff) | |
download | perl-619bbb9ab0f3cffda05f980b2ebb5bf660ad6962.tar.gz |
make loop control apply to "given"
A "given" construct is now officially a one-iteration loop.
Diffstat (limited to 'pod/perlsyn.pod')
-rw-r--r-- | pod/perlsyn.pod | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod index cb12a3590f..480b352e7c 100644 --- a/pod/perlsyn.pod +++ b/pod/perlsyn.pod @@ -638,7 +638,11 @@ independently and mixed with other kinds of compound statement. C<given> evaluates its argument in scalar context, and executes its block with the C<$_> variable locally aliased to the result of evaluating the argument expression. It is much like a C<foreach> loop that always has -exactly one item to iterate over. Either a C<given> or a C<foreach> +exactly one item to iterate over. +A C<given> construct even counts as a one-iteration loop for the purposes +of loop control, so the C<redo> operator can be used to restart its block, +and C<next> or C<last> can be used to exit the block early. +Either a C<given> or a C<foreach> construct serves as a I<topicalizer>: C<when> can only be used in the dynamic scope of a topicalizer. @@ -697,7 +701,8 @@ so providing the subroutine's return value, it evaluates to: =item * -An empty list as soon as an explicit C<break> is encountered. +An empty list as soon as an explicit C<break>, C<next>, or C<last> +is encountered. =item * |