![]() |
|
Perl-Sensitive Sunglasses | |
PerlMonks |
IO::Tee not behaving correctlyby grinder (Bishop) |
on Mar 13, 2002 at 08:28 UTC ( #151332=perlquestion: print w/replies, xml ) | Need Help?? |
grinder has asked for the wisdom of the Perl Monks concerning the following question: Fellow monks, I have a really hairy problem with IO::Tee that I can't resolve. I am using IO::Tee to print to STDOUT and a log file at the same time. In this way, anything that is written to STDOUT is, theoretically, guaranteed to be written to the log file as well, which comes in handy when I have to trace why something didn't work correctly. The problem is that at the end of the program, the log file is of length zero, and yet everything is correctly printed to STDOUT. I created a test program, but that works flawlessly. It goes something like this:
I thought it might have been problems with a missing \n on the last line, or needing to flush explicitly, but that doesn't change things. The test script works, but not the main script. Elsewhere in the script I am using arrays of arrays of IO::File objects which behave as advertised. At no point do I do any bare prints (to STDOUT), everything is printed via the logger object. If, in the main script, I create the $logger object, print to it and exit immediately, the output gets recorded in the log file. Something down the track seems to be making things go haywire, and I am at a loss as to explain why. I am using 5.6.0, which is the most suspicious thing I can think of. For instance, I am not using sfio. Any tips or suggestions for things to try are most appreciated. print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'
Back to
Seekers of Perl Wisdom
|
|