use Filter::Handle qw/subs/; ## $LOG_FH is a FileHandle reference... Filter \*STDERR, sub { local $_ = @_; if (defined $LOG_FH) {print $LOG_FH "STDERR: $_";} $_ }; ## Need a signal handler to capture warnings from carp ## and warn which are not captured by Filter::Handle ## (but by capturing ourselves and printing to STDERR, ## they do get picked up by Filter::Handle)... $SIG{__WARN__} = sub { local $_ = "@_"; print STDERR $_; };