A
Andry
Hi all,
I have a problem trying to "tee" STDOUT at some intervals, opening and
closing filehandles.
The following is a sample script:
******************************************************************
#!/usr/bin/perl -w
use File::Tee qw(tee);
$|=1;
open my $target1, '>', 'log1.txt';
tee STDOUT, $target1;
print "line one\n";
close $target1;
open my $target2, '>', 'log2.txt';
tee STDOUT, $target2;
print "line two\n";
close $target2;
*******************************************************************
Given the above script, I expect to write "line one" in log1.txt and
"line two" in log2.txt.
Instead I get both "line one" and "line two" in log1.txt (while
log2.txt only includes "line two").
So I cannot manage to close log1.txt after printing "line one".
Can anyone help with that?
Thank you,
Andrea
I have a problem trying to "tee" STDOUT at some intervals, opening and
closing filehandles.
The following is a sample script:
******************************************************************
#!/usr/bin/perl -w
use File::Tee qw(tee);
$|=1;
open my $target1, '>', 'log1.txt';
tee STDOUT, $target1;
print "line one\n";
close $target1;
open my $target2, '>', 'log2.txt';
tee STDOUT, $target2;
print "line two\n";
close $target2;
*******************************************************************
Given the above script, I expect to write "line one" in log1.txt and
"line two" in log2.txt.
Instead I get both "line one" and "line two" in log1.txt (while
log2.txt only includes "line two").
So I cannot manage to close log1.txt after printing "line one".
Can anyone help with that?
Thank you,
Andrea