Well, a quick solution would be IO::Tee. This should be nearly a drop-in replacement. A more comprehensive solution would be Log::Log4perl.
I have no way to test this tonight, mayhapse another monk will correct me if wrong, but to assign an IO::Tee to, say, STDOUT would be done something like this:
local *STDOUT = new IO::Tee(\*STDOUT, '>file.txt');
UPDATE: No, after looking at that, I don't think that will work. This is more likely too, but there is probably a shorter way:
open STDOUT, '>&', new IO::Tee(\*STDOUT, '>file.txt');
With this method, you can do silly things like:
# Append open STDOUT, '>>&', new IO::Tee(\*STDOUT, '>file.txt'); # Save the extra file descriptor open STDOUT, '>&=', new IO::Tee(\*STDOUT, '>file.txt'); open STDOUT, '>>&=', new IO::Tee(\*STDOUT, '>file.txt');
See open for more details.
Ted Young
($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)In reply to Re: Porting Perl 5.6 to Perl 5.8 issue with self-tie
by TedYoung
in thread Porting Perl 5.6 to Perl 5.8 issue with self-tie
by fwashbur
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |