in reply to Re: Sending output to an xml file
in thread Sending output to an xml file
It has the advantage of keeping things simple in the perl script, while also keeping the script very flexible (e.g. output can be piped to some other process, in addition to being redirected to a file). No worries about hard-coding an output file name, and no need to handle an extra element in @ARGV or whatever.
On many systems, if there is an "open failed for output" type of error, redirection will trap that before the script is even read, let alone waiting for the perl interpreter to load. (That is, given a command line with piping or redirection, a proper shell will open the file or process at the end of the command first, and stop with an error report if that fails.)
On the whole, for scripts whose purpose is to generate any sort of output data stream, printing to STDOUT within the script and using redirection as needed can usually be considered the preferred approach.
|
|---|