Re: Can Perl redirect STDOUT to file AND to command window?



Thanks for the start, IO::Tee works well like this:

use strict;
use IO::Tee;

my $tee = IO::Tee->new(\*STDOUT,">out.txt");
print $tee "test\n";

However, I am looking for something like this where I dont need to
print to the $tee handle:

use strict;
use IO::Tee;

my $tee = IO::Tee->new(\*STDOUT,">out.txt");
open(STDOUT, ">&$tee");
print "test\n";

This creates out.txt and prints "test" to the screen but not to out.txt

Do I need to use tie() ?

tie(*STDOUT, "mypackage");

R

.



Relevant Pages