Need help on a Perl 5.6 - 5.8 porting issue.
am 08.12.2006 21:58:46 von fwashburHi Folks,
I have a problem for which I can't seem to find a solution. We have a
huge 5.6 code base and are looking at porting to 5.8. Most everything is
going well except for one area.
We took advantage of what sounds like a hole in 5.6 and did a self-tie
of STDOUT to itself and a log file. STDERR was tied to the same log file
and itself. This allowed us to capture all print/printf output in text
logs from sessions with both STDOUT and STDERR as well as seeing this
output on the screen. 5.6 was somehow able to detect that it needed to
call print with the real handle one time and not recurse.
On 5.8, the upgrade notes say self tie is not allowed and in fact it
does cause a recursive call to print.
I have tried saving a global value for STDOUT, doing a local STDOUT and
passing the global value to the Tie class and print to that. This works,
but I can only get either STDOUT or STDERR to work in this situation,
not both.
I have tried using the suggestion from the Perl Cookbook 7-18
open(STDOUT, "| tee $outfile);
print "whatever\n";
close(STDOUT);
Which fails miserably. There are several problems with this. Upon close,
the tee process does not die. Attempts to kill the tee process after the
close result in tee not being able to run again during that process (it
complains about arguments???) Also upon close, STDOUT is now undef and
cannot be used unless opened again. If I open another log file after
closing the first, all print output now goes to the 1st AND 2nd file.
I have tried overriding print and that seems like it is not allowed.
Perhaps there is a way to do this that I have not found, but it needs to
work for both STDOUT and STDERR.
If anyone has ideas on how to:
1. cause output from print and printf
2. for both STDOUT and STDERR
3. to go to successive log files within the same perl session
I would be extremely grateful.
Thanks - Rick
Rick Washburn
Qualcomm Inc. 928-478-4663
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs