Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query. #1038

Closed
p5pRT opened this issue Jan 14, 2000 · 2 comments
Closed

Query. #1038

p5pRT opened this issue Jan 14, 2000 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 14, 2000

Migrated from rt.perl.org#1989 (status was 'resolved')

Searchable as RT1989$

@p5pRT
Copy link
Author

p5pRT commented Jan 14, 2000

From manoj@nortelnetworks.com

I have a query on Perl I/O I am using in my scipt and I would highly appreciate if you could
help me out with this.

Program


$file="output";
open(FL,">>$file");

while (<>)
{
  print FL $_;
}

close(FL);


The above program "read.pl " takes input from STDIN and writes to a file "output".

QUERY : But the write takes place only after the loop is exited and the file is closed.

Is there a way where we can flush the buffer and have it written in the while loop itself.
I looked for a flush function but could not find one.

Any suggestions ?

Thanks in advance,

Manoj

@p5pRT
Copy link
Author

p5pRT commented Jan 14, 2000

From @tamias

On Fri, Jan 14, 2000 at 06​:31​:15PM -0500, Manoj Raghavan wrote​:

Is there a way where we can flush the buffer and have it written in the
while loop itself. I looked for a flush function but could not find one.

This is explained in Perl's FAQ. perlfaq5​:

How do I flush/unbuffer an output filehandle? Why must I do this?

Ronald

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant