in reply to Catching STDERR

I can't guarantee the robustness of this solution, but trying opening STDERR for writing:

use strict; use warnings; open STDERR, "> somefile.txt" or die $!; die "We're dead!";

This works for me, but no guarantees as I've never tried to redirect STDERR.

Cheers,
Ovid

Vote for paco!

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Replies are listed 'Best First'.
Re: (Ovid) Re: Catching STDERR
by tye (Sage) on Jun 27, 2001 at 09:47 UTC

    Just a little FYI: Ovid's doubts are unfounded as this is the most reliable way of catching STDERR. I clicked to this thread fearing I'd see lots of advice to use $SIG{__DIE__}, eval, CORE::GLOBAL::die, tie, pipe-and-fork... A simple open is much preferred. (:

            - tye (but my friends call me "Tye")