The perl script doesn't have to bother opening a specific output file at all; it just prints. (STDOUT is the default output file handle.) Plus, no more worries over forgetting to include quotes on the command line -- just let the shell do what it's supposed to do.perl script.pl > outfile # create new or truncate existing outfile perl script.pl >> outfile # create new or append to existing outfil +e
That also allows you to use the script in yet another handy way (and the last time I checked, the "standard" windows cmd.exe handles all three modes the same way unix and linux do - it's portable!):
That's what we call elegant.perl script.pl | some_other_process ...
In reply to Re: Append to file or create file depending on input filename.
by graff
in thread Append to file or create file depending on input filename.
by markuhs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |