I seem to remember that last/next/redo are implemented as edge cases of
goto LABEL.
Provided the target label is set it's possible to goto out of a sub into a scope in the dynamic caller chain. (One use case is to short circuit leaving a recursion, without needing to step thru hundreds of returns*)
So this behavior doesn't surprise me. (Though I would have expected to see a label)
My bet is the documentation is wrong or badly worded or at least outdated.
update
*) demo
use strict;
use warnings;
use 5.12.0;
sub count_down {
my ($a)=@_;
say --$a;
goto EXIT unless $a;
count_down($a)
}
count_down(10);
say "never reached";
EXIT:
say "byebye";
9
8
7
6
5
4
3
2
1
0
byebye
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.