Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
laziness, impatience, and hubris
 
PerlMonks  

Re^2: die in a DESTROY

by water (Chaplain)
on Sep 27, 2005 at 19:19 UTC ( #495515=note: print w/ replies, xml ) Need Help??


in reply to Re: die in a DESTROY
in thread die in a DESTROY

 die is the same as  print STDERR "message"; exit(1) ???

Really?

Never knew that! Is in docs somewhere?

How does  print STDERR "message"; exit(1) work with eval then?

water


Comment on Re^2: die in a DESTROY
Select or Download Code
Re^3: die in a DESTROY
by sauoq (Abbot) on Sep 27, 2005 at 19:55 UTC
    die is the same as print STDERR "message"; exit(1) ???

    Well, it's not exactly the same. Specifically, the status you exit with shouldn't necessarily be 1 if you want a perfect emulation. But, the right status to exit with is easy enough to determine. See below.

    Never knew that! Is in docs somewhere?

    The first paragraph of the perlfunc entry for die states:

    die LIST Outside an "eval", prints the value of LIST to "STDERR" and exits with the current value of $! (errno). If $! is 0, exits with the value of "($? >> 8)" (backtick `command` status). If "($? >> 8)" is 0, exits with 255.

    How does print STDERR "message"; exit(1) work with eval then?

    Exactly like you would expect. Since exit doesn't care whether you are in an eval or not, it will work fine. It's only because die has special behavior inside an eval that you are running into problems.

    -sauoq
    "My two cents aren't worth a dime.";
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2014-04-16 15:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (431 votes), past polls