STDOUT

Kevin Cozens kcozens-qazKcTl6WRFWk0Htik3J/w at public.gmane.org
Sun May 16 14:57:54 UTC 2004


At 01:17 AM 05/16/2004, Alan Cohen wrote:
>I have a perl program that gets its input from another program's STDOUT.
[snip]
>Currently, I'm storing everything from STDIN to an intermediate file,
>making my decision and then writing either a hard-coded message or the
>intermediate file to STDOUT.
>
>Is there a way that doesn't require the intermediate file?

It would depend in part on the amount of data being passed to your Perl script.

One option would be to start the Perl script with:
@lines = <STDIN>;

This will cause the program to read in everything passed to it in to memory 
in one fell swoop. You can then iterate through the contents of the lines 
array to make the decision you need to make. Then you would either write 
your hard-coded message or 'print (@lines);' to output the original file.


Cheers!

Kevin.  (http://www.interlog.com/~kcozens/)

Owner of Elecraft K2 #2172        |"What are we going to do today, Borg?"
E-mail:kcozens at interlog dot com|"Same thing we always do, Pinkutus:
Packet:ve3syb-XXPEJ3/fxIc at public.gmane.org#con.on.ca.na|  Try to assimilate the world!"
#include <disclaimer/favourite>   |              -Pinkutus & the Borg

--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list