You could reverse the logic of your sub:
if ($file) { open LOGFILE, ">>$file" or die "Error message: $!\n"; } else { open LOGFILE, ">&STDERR" or die "Another error\n"; } print LOGFILE "blah blah"; close LOGFILE or die "Yet another error\n";
-- TMTOWTDI
In reply to Re: Cleaner redirection of STDERR
by trantor
in thread Cleaner redirection of STDERR
by rob_au
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |