http://qs321.pair.com?node_id=638077


in reply to Re^6: bad die behaviour?
in thread bad die behaviour?

You might want to consider using $SIG{__DIE__} instead of the FatalError subroutine. Put what you are doing in the FatalError into the subroutine for the DIE signal handler, evaluate $? (instead of $!) before die'ing.

Something like:

$SIG{__DIE__}=sub{ print STDERR "I'm Dyin!: \n"; }; some_command; $error_code=$?>>8; print "Finished running some_command"; die if $error_code > 0;