Why not simply pass the filename of the file-to-be-written to the program, and let it do the file writing in any case?Because if I do this, I don't get any diagnostics about the error case. Note that I still *guess* what's going on, so for example the information "STDOUT in the error case is still connected to the same stream as in the parent" would be helpful.
On Linux, the -p file test can tell you if STDOUT is connected to a pipe, no idea if that works on windows too (Update: -t is probably more informative than -p).There is an entry in perlfaq8 about this, which is not very encouraging:
How do I find out if I'm running interactively or not? Good question. Sometimes "-t STDIN" and "-t STDOUT" can give clues, sometimes not. if (-t STDIN && -t STDOUT) { print "Now what? "; }
In reply to Re^2: Test whether STDOUT is connected to a file
by rovf
in thread Test whether STDOUT is connected to a file
by rovf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |