Question, as it has come up in this thread twice, and that is the issue of die() vs exit((). The Camel states that one should not exit a subroutine when an error needs to be trapped. But if not, is die necessary, or is exit sufficient?
Comments?
—Brad "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
| [reply] |
eval {
print "Inside\n";
die;
};
print "Outside\n";
----
Inside
Outside
vs.
eval {
print "Inside\n";
exit;
};
print "Outside\n";
----
Inside
exit() exits, end of story. die() allows for some manner of error trapping. This is the main reason why die() is preferred within subroutines. You may want to reuse that subroutine somewhere else that wants to be able to trap the abnormal termination. Also, die() triggers $SIG{DIE}, which can also be useful to trap.
| [reply] [d/l] [select] |
You can trap an exit (termination of a script) as well.
END { print "Outside"; }
eval {
print "Inside\n";
exit;
};
print "Outside\n";
----
Inside
Outside
-- gam3
A picture is worth a thousand words, but takes 200K.
| [reply] [d/l] |
| [reply] |