Re: Can Perl redirect STDOUT to file AND to command window?
- From: rcm228@xxxxxxxxx
- Date: 29 Nov 2005 15:09:44 -0800
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
.
- Follow-Ups:
- References:
- Prev by Date: FAQ 5.36 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl?
- Next by Date: Re: Can Perl redirect STDOUT to file AND to command window?
- Previous by thread: Re: Can Perl redirect STDOUT to file AND to command window?
- Next by thread: Re: Can Perl redirect STDOUT to file AND to command window?
- Index(es):
Relevant Pages
|