Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: tee and log files

by salva (Abbot)
on May 18, 2012 at 14:08 UTC ( #971312=note: print w/ replies, xml ) Need Help??

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.

Comment on Re: tee and log files
Download Code
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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://971312]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2015-10-10 09:19 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (255 votes), past polls