Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$¦ ?? 1

Status
Not open for further replies.

sleuth

Programmer
Jan 12, 2001
134
US

What good is setting $| to a true value,

I read that it forces a flush after every write or print to the selected output device, and this would be good for ..... ??

Thanks,

Tony "Java?? Umm, I think that's the stuff I drink while I'm coding perl."
 
Here is a great article on buffering that should assist you in understanding. I'm too lazy to reiterate here. ;-)


Essentially, disabling buffering is good when you want to see results right away in a function that could take a very long time to fill (and thus, flush) the print buffer.

You also want to turn off buffering when communicating through TCP/IP sockets and the like. With the typical four letter commands in TCP/IP communication, you probably don't want to wait for an 8 kilobyte buffer to fill before sending it to the remote server.

Leaving buffering enabled is good when you're working with the filesystem.

Hope this helps,

brendanc@icehouse.net
 

Thank You, that article was very informative,

At first I got the impression from reading your post that when you do something like this

print "Starting..";
$|=1;
open(data, &quot;<bigassdatabase.db&quot;);
while(<data>){
#do something that takes a long time
}
close(data);

Then you'd see the text before the script was even finished running, how cool that would have been, hehe.

Tony &quot;Java?? Umm, I think that's the stuff I drink while I'm coding perl.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top