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

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

Thread Previous
From:
Enache Adrian
Date:
March 4, 2003 22:02
Subject:
Re: [perl #20823] BEGIN { local $@; die 'foo' } doesn't die
Message ID:
20030305060425.GA20247@ratsnest.hole
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
script.
(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
problems.

Thanks & Regards

Adi

Thread Previous


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