After much programming and processing, I finally have my
data ready for the last step - I want to run it (basically
a text file) through a program (call it foo), and write out
the processed file.
I have tried to search for ways to do this, but two-way
pipes seem fairly complicated. Should I write the file to
a temporary file, and use foo to read that file (it can
read from a file or STDIN, and always writes to STDOUT
without redirection), and grab STDOUT, and write that to
a file?
A search seems to tell me that the preferred way is to
do something like:
open(PIPE_FROM_FOO, -|);
But I still didn't see how to call foo in the examples
(they mostly concerned writing to a pipe).
I have my textfile in a variable called $myfile. Can someone
tell me the "best" way (or any good way), to run it through
foo?
update (broquaint): title change (was piping)
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.