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