in reply to Re: Capturing all (and I mean all) output to a file
in thread Capturing all (and I mean all) output to a file

Looks good...

Only thing I can't do now is redirect STDERR to the $tee filehandle... Not sure if I've misinterpreted the IO::Tee instructions, or just have a poor grasp of IO operations!

See test code here:

use IO::Tee; use strict; my $tee = new IO::Tee(\*STDOUT, ">outfile.out"); #Test normal output print $tee "normal data\n"; #Test system commands my $cmdout = `dir /w`; print $tee $cmdout."\n"; #Check input questions work print $tee "Enter some data\n"; my $input = <>; print $tee $input; #Check stderr also goes to the file + screen. warn "Warning here\n";

Replies are listed 'Best First'.
Re^3: Capturing all (and I mean all) output to a file
by chb (Deacon) on Jan 12, 2005 at 11:31 UTC
    Isn't it possible to redirect/reopen STDERR to STDOUT _before_ you call new IO::Tee ?
      I don't think so - STDOUT doesn't go to the file -- it's the $tee filehandle that does the work... Need to direct STDERR to $tee, but my best guess, open (STDERR, ">$tee") doesn't work...

        No but

        open STDERR, ">&", $tee;
        will.

        /J\