I want to clone the output to the console as well as to a log file simultaneously. Here is my code snippet:
open STDOUT, ">>", "temp.txt" or die "";
system("echo This is a sample output..........");
But, here I only get output in the temp.txt
and not on the console.
Can you suggest a solution? I am using Windows.
It will output to STDOUT
and temp.txt
,
use Capture::Tiny::Extended 'tee';
tee(
sub {
system("echo This is a sample output..........");
},
{ stdout => "temp.txt" }
);