ForgotPasswordAgain has asked for the wisdom of the Perl Monks concerning the following question:
Edit:$ perl -Mstrict -wE'$SIG{__DIE__}=sub{last}; die "hi"' Exiting subroutine via last at -e line 1. Can't "last" outside a loop block at -e line 1. # no strict $ perl -wE'$SIG{__DIE__}=sub{last}; die "hi"' Exiting subroutine via last at -e line 1. Can't "last" outside a loop block at -e line 1. # no warnings $ perl -E'$SIG{__DIE__}=sub{last}; die "hi"' Can't "last" outside a loop block at -e line 1. # -e instead of -E $ perl -e'$SIG{__DIE__}=sub{last}; die "hi"' Can't "last" outside a loop block at -e line 1. # put last in a while loop, dies $ perl -e'$SIG{__DIE__}=sub{while(1){last}}; die "hi"' hi at -e line 1. # put last in a non-loop block, dies $ perl -e'$SIG{__DIE__}=sub{{last}}; die "hi"' hi at -e line 1.
$ perl --version This is perl 5, version 38, subversion 2 (v5.38.2) built for x86_64-ms +ys-thread-multi
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: exit from $SIG{__DIE__} via a loop exit?
by choroba (Cardinal) on Mar 07, 2025 at 10:15 UTC | |
by ForgotPasswordAgain (Vicar) on Mar 08, 2025 at 03:47 UTC | |
|
Re: exit from $SIG{__DIE__} via a loop exit?
by Corion (Patriarch) on Mar 07, 2025 at 06:48 UTC | |
|
Re: exit from $SIG{__DIE__} via a loop exit?
by ikegami (Patriarch) on Mar 07, 2025 at 15:48 UTC | |
by ForgotPasswordAgain (Vicar) on Mar 08, 2025 at 03:49 UTC |