By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,842 Members | 1,426 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,842 IT Pros & Developers. It's quick & easy.

reading from stdin via pipe, buffering?

P: 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
Feb 29 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Rudy Gevaert" <Ru************@ugentspam.bewrote in message
news:fq**********@gaudi2.UGent.be...
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 $|++;

Mar 9 '08 #2

P: n/a
Rodrick Brown wrote:
>
"Rudy Gevaert" <Ru************@ugentspam.bewrote in message
news:fq**********@gaudi2.UGent.be...
>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.
Mar 15 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.