sub mysub { my $error = shift; print STDERR "mail stuff here..\n"; print STDERR "Error message: $error"; print STDERR "End of mail\n"; die $error; } local $SIG{__DIE__} = \&mysub; open(TMPFILE,"