sub f { last; }
say "before loop";
{
say "start of loop";
f();
say "end of loop";
}
say "after loop";
({ ... } is technically a loop. You can also use while/until loop, a foreach loop, or a C-style for loop.)
This outputs
before loop
start of loop
Exiting subroutine via last at -e line 1.
after loop
So the documentation you quoted refers to programs such as the following:
$SIG{ __DIE__ } = sub { last; };
say "before loop";
{
say "start of loop";
die "!";
say "end of loop";
}
say "after loop";
However, the code doesn't do what the documentation claims it does.
before loop
start of loop
Can't "last" outside a loop block at -e line 1.
choroba pointed out that the documentation was corrected a short while ago.
However, the documentation is wrong, and it was corrected a short while ago. (Thanks to choroba for identifying this.)
|