use warnings; use strict; use Carp; my $cleanup = sub { print "helper cleans up after itself!\n"; }; local $SIG{__DIE__} = $cleanup; print "Hello\n"; croak "bad thing"; print "There\n"; 1;