sub tee_print { print MYLOGFILE $_[0]; print $_[0] } eval { local $SIG{__WARN__} = \&tee_print; my $h = MyModule->new(PrintHandler => \&tee_print); $h->method($params) or tee_print("oops: " . $h->errstr()); }; if ($@) { tee_print("error: $@") }