Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: die in a DESTROY

by water (Deacon)
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) ???


Never knew that! Is in docs somewhere?

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


Replies are listed 'Best First'.
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.

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (1)
As of 2020-10-25 04:25 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (249 votes). Check out past polls.