View Single Post
Old 07-25-2002, 01:31 PM  
NetRodent
Confirmed User
 
Join Date: Jan 2002
Location: In the walls of your house.
Posts: 3,985
Here's what the perl documentation has to say about the $| variable at http://www.perldoc.com/perl5.6/pod/perlvar.html

Quote:
autoflush HANDLE EXPR
$OUTPUT_AUTOFLUSH
$|
If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0 (regardless of whether the channel is really buffered by the system or not; $| tells you only whether you've asked Perl explicitly to flush after each write). STDOUT will typically be line buffered if output is to the terminal and block buffered otherwise. Setting this variable is useful primarily when you are outputting to a pipe or socket, such as when you are running a Perl program under rsh and want to see the output as it's happening. This has no effect on input buffering. See perlfunc/getc for that. (Mnemonic: when you want your pipes to be piping hot.)
So to answer your question, setting the $| changes the buffering on all output including files. Of course you can do something like
this:

Code:
#!/usr/bin/perl -wT
$| = 1; # unbuffer this
print "Location:http://www.nba.com/\n\n ";
$| = 0; # buffer everything else
open(LOG, ">>log");
print LOG "blah blah blah\n";
close LOG;
exit;
It also appears that you may be able to set the buffering on particular output channels. Try reading the perl IO faqhere.
NetRodent is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote