develooper Front page | perl.perl5.porters | Postings from August 2001

To END or not to END (when dead in a BEGIN)?

Thread Next
From:
Arthur Bergman
Date:
August 29, 2001 01:18
Subject:
To END or not to END (when dead in a BEGIN)?
Message ID:
B7B271FD.3612%arthur@contiller.se

Playing around a bit with the new run END in perl_destruct code, I notice
that we changed behaviour a bit.

In perl 5.6.1
artur@sc-lab1:~/perl/build$ perl -le 'END{print "END"} BEGIN{ die "BEGIN"}'
BEGIN at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

In bleadperl
artur@sc-lab1:~/perl/build$ ./perl -le 'END{print "END"} BEGIN{ die
"BEGIN"}'
BEGIN at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
END


So all known end blocks are run if you die() inside a BEGIN {}.

Reading from perlmod this behaviour seems to be correct (and the old one not
complete).

       An "END" subroutine is executed as late as possible, that
       is, after perl has finished running the program and just
       before the interpreter is being exited, even if it is
       exiting as a result of a die() function.

I would think the new behaviour is more correct, otherwise we need to change
this part of the documentation.

-- 
Arthur


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About