- or download this
eval {
... code that might die ...
...
# if we had an error.
... read $@ and decide on what to do ...
}
- or download this
$SIG{__DIE__} = \&my_death;
...
warn @_; #propagate the message via warn()
POSIX::_exit(42); #exit with code 42
}
- or download this
sub main {
... main program logic ...
...
if ($@) {
... handle any fatal errors ...
}
- or download this
eval { main() };
if ($@) {
...
close_all_files();
issue_done_to_server();
}