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

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

Thread Previous | Thread Next
March 5, 2003 14:43
Re: [perl #20823] BEGIN { local $@; die 'foo' } doesn't die
Message ID:
On 5 Mar 2003 06:02:33 -0000, wrote:
>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).

I will take a look when I get a chance.

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

Not sure what you mean by catch/un-catchable here.  Maybe it will be
clear when I look at the code.

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

Not that I can find.

>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

AFAICT from the documentation, the local should have
*no* effect on the die, and the die should end the program (unless the
BEGIN block is in a string eval, of course.)

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