Connecting Tech Pros Worldwide Help | Site Map

reading from stdin via pipe, buffering?

  #1  
Old February 29th, 2008, 04:15 PM
Rudy Gevaert
Guest
 
Posts: n/a
Hi,

I have written an perl program that read from stdin:
while(<STDIN>)
{
chomp
do_it($_);
}
Data is fed to it via a pipe:

cat myfile | ./myprogram

When running the program, the program doesn't always read the whole
line. I'm guessing this has something to do with the stdin buffer.

I would like to know how I can make that perl gets the whole line. As
it is clearly failing from time to time.

Thanks in advance,

Rudy


  #2  
Old March 9th, 2008, 09:45 PM
Rodrick Brown
Guest
 
Posts: n/a

re: reading from stdin via pipe, buffering?



"Rudy Gevaert" <Rudy.Gevaertno@ugentspam.bewrote in message
news:fq942i$357$1@gaudi2.UGent.be...
Quote:
Hi,
>
I have written an perl program that read from stdin:
while(<STDIN>)
{
chomp
do_it($_);
}
Data is fed to it via a pipe:
>
cat myfile | ./myprogram
>
When running the program, the program doesn't always read the whole line.
I'm guessing this has something to do with the stdin buffer.
>
I would like to know how I can make that perl gets the whole line. As it
is clearly failing from time to time.
>
Thanks in advance,
>
Rudy
>
>
Try disabling buffering $|++;

  #3  
Old March 15th, 2008, 09:45 AM
Joe Smith
Guest
 
Posts: n/a

re: reading from stdin via pipe, buffering?


Rodrick Brown wrote:
Quote:
>
"Rudy Gevaert" <Rudy.Gevaertno@ugentspam.bewrote in message
news:fq942i$357$1@gaudi2.UGent.be...
Quote:
>When running the program, the program doesn't always read the whole
>line. I'm guessing this has something to do with the stdin buffer.
>>
>
Try disabling buffering $|++;
Won't help. $| controls output buffering; it has no affect on STDIN.
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 13th, 2005 11:37 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 13th, 2005 09:56 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 13th, 2005 03:15 AM
Python Interactive Shell - outputting to stdout? Avi Berkovich answers 6 July 18th, 2005 08:23 PM