Dear Monks:
This seems so simple, yet I've not found a clue in the O'Reilly book nor an extensive library of scripts at my disposal:
I need to process either a stream of millions of data points or a single atom with the same script:
> cat stream | foo
> foo bar (where bar is a single element form the stream)
I'm using the following convenient method to processing a stream from STDIN:
while (<>){
process stuff---
}
I tried this hack:
if ($ARGV[0]) {$inline = $ARGV[0]}
do{
process stuff--
}while ($inline = <>);
Course, now perl thinks $ARGV[0] is a file for input,
and if I delete @ARGV, perl now waits patiently on STDIN.
I need to be able to disable STDIN when an invocation argument is suppplied. Is that possible?
thanks!
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.