use Silly::Die; EXPR or die trying; #### open FILE, "foo" or die trying; #### package Silly::Die; sub import { my $class = shift; my $caller = caller; no strict 'refs'; *{"${caller}::trying"} = \&{"${class}::trying"}; } sub trying { $! } 1;