package Silly::Die; use strict; use vars qw/$OUTPUT/; sub import { my $class = shift; my $caller = caller; no strict 'refs'; *{"${caller}::trying"} = \&{"${class}::trying"}; $OUTPUT = shift if @_ && ref $_[0] eq "CODE"; } sub trying { $OUTPUT ? $OUTPUT->($!) : $! } 1;