I have Perl script which is executing another script. How can I ensure that, when CONNECTION.pl is executed, I will capture STDERR and STDOUT, so that I can put it in the log in the parent script? Bellow is the code from the parent script:
my $systemcmd ='perl bin/CONNECTION.pl "'.$expanded_sql.'" "'.$tmp_file.'" "'.$fetch.'"';
eval {
my $rc = system($systemcmd );
};
if ($@) {
$errmsg = $@;
croak {message=>$errmsg};
unlink $tmp_file;
}