in reply to Which is a better, more prudent way to redirecting STDOUT?
A couple more possibilities:
or else{ local *STDOUT; open STDOUT, '>>', "$logbin/$logname" or die $!; # ... }
The choice depends most on what fits your program design.open LOG, '>>', "$logbin/$logname" or die $!; # ,,, { my $oldout = select LOG; # ... log stuff select $oldout; }
The case you need to worry about with your code is when STDOUT has been redirected someplace else. You want to restore it to what it was when you exit the logging block. Hemce local.
After Compline,
Zaxo
|
|---|