Hi all,
I wrote a program for work (I'm an undergraduate intern who taught himself Perl in about 3 weeks) that basically generates a giant report and dumps it to the terminal. It works great, but I'd like people to be able to pipe it to either dump to a file or use the "more" command, as in these examples:
$ my_program > w00t.txt
$ my_program | more
I can easily implement either of these features from within the program, but I'd like to be able to this to make the program more "UNIX-like". I don't want to make people learn some new switch/flag/whatever when it's possible to use the UNIX pipes, especially if people want to use "cat", "lpr" or "grep", etc.
I'm not going to post the code here; it's pretty long, irrelevant to the question, and essentially the print to STDOUT happens within the last 5 lines.
So, how do I pipe my output to, say, "more"?
Thanks for all the help!
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.