#... $SIG{'INT'} = 'cleanup'; # we want to rewind tape & write to log $SIG{'HUP'} = 'cleanup'; # we want to rewind tape & write to log # later... sub cleanup { # Normal is set to true if the script has got through the # rest. &report("\nAbnormal exit, cleaning up") unless $normal; if ($normal) { &eject(); } else { &rewind(); &eject() if $opt{e}; } # Report and other stuff here deleted. }