I am looking for a way to redirect STDOUT (and STDERR also) from system function to a log file and also to the screen. The sample script shown below will redirect the print statement's output to both just fine; however, only system's return value is redirected to both the log and displayed on the screen. Does anyone know of a way to redirect the output from the command (cleartool) that system is passed to both the screen and the log file? I am running my script on Windows XP.
This is my first posting and I am not a perl expert. Your help would be greatly appreciated. Thanks in advance.
use IO::Tee;
my $tee = IO::Tee -> new(">stdout.log", \*STDOUT);
print $tee system("cleartool describe lbtype:MYLABEL");
print $tee "\nThis will print to screen and redirects to file!\n";