local $SIG{__DIE__} = sub { local $|++; # autoflush print STDERR @_; }; unlink 'test.errors'; redirect_error( output_file => 'test.errors' ); # call this directly, not in an eval, as you're trapping the croak lcroak "this is a sample error file"; ok( -T 'test.errors', "lcroak opens the error file specified by redirect_error()." ); my $text = `cat test.errors`; like( $text , qr/this is a sample error file/, "lcroak writes to the error file specified by redirect_error()." ); unlink 'test.errors';