Subject: | IO::All append fails on stdout "-" |
I am trying to use the pattern:
use IO::All;
sub doThing
{
my $log = io($LOG_FILE_NAME);
$log->append("Log Message 1\n");
$log->append("Log Message 2\n");
}
if $LOG_FILE_NAME is "-" (for stdout)
I get a "bad file descriptor at ..."
error.
My current work around is to do the following:
sub doThing
{
my $log = io($LOG_FILE_NAME);
$log->append("Log Message 1\n") unless $log->is_stdio;
"Log Message 1\n" > $log if $log->is_stdio;
$log->append("Log Message 2\n");
}
After the if/unless, I can call append for both cases without issue.