Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Rethrowing with die $@ considered harmful

by shmem (Chancellor)
on Jul 18, 2006 at 08:21 UTC ( [id://561961]=note: print w/replies, xml ) Need Help??


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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://561961]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-03-29 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found