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

I think you probably want to look at the module IO::Tee

/J\

  • Comment on Re: Capturing all (and I mean all) output to a file

Replies are listed 'Best First'.
Re^2: Capturing all (and I mean all) output to a file
by flippy (Novice) on Jan 12, 2005 at 11:20 UTC

    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";
      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...