in reply to How do I output error messages to a file?

Reopening STDERR is right, but there is an other solution too, using $SIG{__DIE__} as follows (untested code):

BEGIN{ open LOGFILE, ">>", "/path/to/log" or die "cannot open logfile: $!"; $SIG{__DIE__}= sub { print LOGFILE $_[0]; } $SIG{__WARN__}= sub { print LOGFILE $_[0]; } }