http://www.perlmonks.org?node_id=971312


in reply to tee and log files

use File::Tee:
use File::Tee qw(tee); open my $LOGFILE, '>>', $logFileName or die $!; tee STDOUT, '>>&', $LOGFILE or die $!; ...
update: I am thinking that this is not going to work properly either, because the tee work is done by a subprocess and so there is a race condition.

In this case, IO::Tee that uses a tied file handle to duplicate the output may be a better option.

Replies are listed 'Best First'.
Re^2: tee and log files
by not-a-monk (Novice) on May 18, 2012 at 15:21 UTC
    Thank you for your suggestions but due to my circumstances I am trying to implement this solution without using CPAN or similar non-standard libraries.