develooper Front page | perl.perl5.porters | Postings from March 2003

Re: [perl #20823] BEGIN { local $@; die 'foo' } doesn't die

Thread Previous
Enache Adrian
March 4, 2003 22:02
Re: [perl #20823] BEGIN { local $@; die 'foo' } doesn't die
Message ID:
On Mon, Feb 10, 2003 at 08:44:08PM -0000, Yitzchak Scott-Thoennes wrote:
> BEGIN { local $@; die 'foo' } seems to bail out of the BEGIN, but doesn't
> actually die, as if the BEGIN was an eval.

The code in Perl_call_list checks for the length of ERRGV ( aka $@ ),
and if this is zero, thinks all is OK and continues running the
(see perl.c:3958).

There is no other way to catch an exception than checking if ERRGV isn't
clear. Localizing it makes, of course, any exception un-catchable.

Are there any documentation that suggests that
	BEGIN { local $@; die ' ... ' }
should die silently or something like that ?

I ask it because many core modules seems to assume it and it actually
_never_ worked like that. That assumption seems to cause lots of

Thanks & Regards


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About