I have a perl script that requires a --log=<log>
command line parameter. Obviously, this sends the script output to the filename specified. Without changing the script, is there any command-line value I can supply that would send output to STDOUT instead of a log file? When I supply "STDOUT", as you would probably expect, it sends the output to a file named "STDOUT".
Here is the relevant code:
use Getopt::Long;
...
my %C;
my $result = GetOptions("log=s" => \$C{log},
...
);
...
my $log_file = $C{log};
...
my $log_fh;
if(open($log_fh, '>>', $log_file)) {
print $log_fh $txt;
close($log_fh);
} else {
print STDERR "couldn't open log file $log_file\n";
}
I suspect the answer is no, but I was hoping someone wiser than me might have a solution.
Edit: It has been suggested that this is a duplicate of pass stdout as file name for command line util? . While there is some overlap, that question involves a command line utility in an unspecified language. My question relates specifically to Perl, and even more specifically to the code above, and so could potentially have a different answer.