in reply to exit from $SIG{__DIE__} via a loop exit?

This is a loop exit:

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.)

Replies are listed 'Best First'.
Re^2: exit from $SIG{__DIE__} via a loop exit?
by ForgotPasswordAgain (Vicar) on Mar 08, 2025 at 03:49 UTC
    Thanks, so at least I did understand what "exits via a loop exit" meant, but was led astray by the doc mismatch