Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

reading from stdin via pipe, buffering?
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



Report this thread to moderator Post Follow-up to this message
Old Post
Rudy Gevaert
03-01-08 12:01 AM


Re: reading from stdin via pipe, buffering?
"Rudy Gevaert" <Rudy.Gevaertno@ugentspam.be> wrote in message
news:fq942i$357$1@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 $|++;


Report this thread to moderator Post Follow-up to this message
Old Post
Rodrick Brown
03-10-08 12:16 AM


Re: reading from stdin via pipe, buffering?
Rodrick Brown wrote:
>
> "Rudy Gevaert" <Rudy.Gevaertno@ugentspam.be> wrote in message
> news:fq942i$357$1@gaudi2.UGent.be... 
>
> Try disabling buffering $|++;

Won't help.  $| controls output buffering; it has no affect on STDIN.

Report this thread to moderator Post Follow-up to this message
Old Post
Joe Smith
03-15-08 09:15 AM



http://www.CheapVideoBlog.com/e?watch=726071

Report this thread to moderator Post Follow-up to this message
Old Post
Necsy
03-21-08 12:09 AM



http://www.dataplaygames.com//thumb/001.jpg[/url
][url=http://www.dataplaygames.com/Play?id=726648]http://www.dataplaygames.com//thumb/002.jpg
[img]http://www.dataplaygames.com//thumb/00
3.jpg[/img]

http://www.dataplaygames.com//thumb/004.jpg[url
=http://www.dataplaygames.com/PlayMovie.wmv?movie=726648][img]http://www.dataplaygames.com//thumb/005.jpg[/img
][/url][img]http://www.dataplaygames.com//thu
mb/006.jpg[/img]

http://www.dataplaygames.com//thumb/007.jpghttp://www.dataplaygames.com//thumb/008.jpg[img]http://www.dataplaygames.com//thumb/009.jpg[/i
mg]

http://www.dataplaygames.com//thumb/010.jpghttp://www.dataplaygames.com//thumb/011.jpg[img]http://www.dataplaygames.com/
/thumb/012.jpg[/img]

http://www.dataplaygames.com//thumb/013.jpghttp://www.dataplaygames.com//thumb/014.jpg[img]http://www.dataplaygames.com//thumb/015.jpg
[/img]

Report this thread to moderator Post Follow-up to this message
Old Post
Knotlad
04-21-08 03:13 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:24 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.