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; #### qwurx [shmem] ~ > perl main.pl helper.pl Hello helper cleans up after itself! helper.pl: bad thing at helper.pl line 11 require helper.pl called at main.pl line 6 Done with main