in reply to Re^2: Rethrowing with die $@ considered harmful
in thread Rethrowing with die $@ considered harmful

I consider this code buggy. If $@ is set, it must be reported/processed immediately without any further function call. If you just can't die from it, use warn:
eval { foo() } ; if ( $@ ) { warn $@; bar(); } Undefined subroutine &main::foo called at 561955.pl line 2. Undefined subroutine &main::bar called at 561955.pl line 5.

Note: I'm not against copying $@. If you need to make further calls first, copy it and report it later. But inadvertently clearing is a programmer's bug, not perl's fault.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
200th post

Replies are listed 'Best First'.
Re^4: Rethrowing with die $@ considered harmful
by adrianh (Chancellor) on Aug 01, 2006 at 06:23 UTC
    I consider this code buggy. If $@ is set, it must be reported/processed immediately without any further function call.

    I agree. That was my (and I believe the OPs) point!