package Hps; my $origHandler = $SIG{__DIE__}; $SIG{__DIE__} = 'Hps::grimReaper' unless ($^D); sub grimReaper { # We can drop out early if $^S is set because that means we're in an eval die (@_) if (not defined $^S or ($] >= 5.005 and defined $^S and $^S)); # .. do some stuff .. # It is this line that causes an error. $SIG{__DIE__} = $origHandler; die "@_"; } #### #!/usr/bin/perl -w use strict; use Hps; die ("Oh no!");