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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.