Search code examples
perlstdouttee

How to get perl code output to STDOUT/STDERR and a file, in realtime and cross-platform?


I need to get the output of normal Perl code to the screen and into a logfile at the same time. However a problem is that the runtime of the tool can be hours. Using Capture::Tiny's tee that means the log file will only be written to once the script terminates, which is not very useful.

To further complicate things, i need to capture the output of straight perl from the same process, as well as that of processes called with system().

Lastly, due to employer restrictions it needs to work on Win32 as well.

What other options do i have?


Solution

  • Since none of the presented solutions were satisfactory i sat down and solved the problem on my own:

    Capture::Tiny::Extended