in reply to Sending output to an xml file

There are three approaches to this problem:

Replies are listed 'Best First'.
Re^2: Sending output to an xml file
by graff (Chancellor) on Sep 29, 2005 at 02:58 UTC
    Sorry, but I must nit-pick. What you refer to as the "invocation hack" is really not a "hack" at all. Output redirection is a perfectly normal, reasonable and "proper" way of storing output to a 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.