The IPC :: Run module provides a run function that works like a supercharged system . This allows us to collect the output of STDERR and STDOUT in combination:
run [$cmd, @args], '&>', \my $output;
after that, the variable $output contains the combined output as a string.
Example:
use IPC::Run qw/ run /; run ['perl', '-E say "stdout"; say STDERR "stderr"'], '&>', \my $output; print uc $output;
Output:
STDOUT STDERR
I donβt know how to use a file descriptor instead of a scalar link so that I can read the output normally in a while(<$fh>) .
source share