listmail wrote: > I need to tee STDOUT to both STDOUT and a variable. For tee'ing to > STDOUT and a LOGFILE, I've used the older package described at > http://jenda.krynicky.cz/perl/TeeOutput.pm.html for some time and this > works wonderfully. I'm not getting a variable to work and > perhaps its because of a misunderstanding that I have. > > #! /usr/local/bin/perl -w > use strict; > use Local::TeeOutput; > > my $stdout; > > open (TEST, '>', \$stdout); > openTee(*STDOUT, *STDOUT, *TEST); > print "Test line to STDOUT\n"; > closeTee(*STDOUT); > print "Variable: $stdout\n";
my $err; close STDERR; # you have to close stdout/err first open STDERR, '>', \$err; print STDERR "Some stuff\n"; print "\$err='$err'\n"; Same with STDOUT. This only works on late model Perls (not sure which version minimum). _______________________________________________ Perl-Unix-Users mailing list Perl-Unix-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs