From: "Anette Seiler" <[EMAIL PROTECTED]> > I am a newbie in Perl. My boss (who isn't a newbie) has given me one > of his programs. I am now trying to understand this program. > > Right in the beginning it says: > > $| = 1; # flush output after each write or print > > What does it mean?
It does exactly what the comment says. It flushes the output after each write or print :-) Serious ... normaly when you write into a filehandle the data are not written to the disk or sent over the socket immediately. It's just put into a buffer and saved when the buffed is full (or under several other circumstances, like when you close the file or flush the filehandle). While this is more efficient, sometimes you need to actualy save/send the data immediately ... for example because you intend to wait for a reply. Thus you may either flush the filehandle after each print or write statement or turn off the buffering for the filehandle. The $| is a bit crazy way to do it actually. IMHO it should not be used anymore. It turns off the buffering for currently selected filehandle (the one into which you print if you do not specify a filehandle : ' print "Hello World!\n"; '. By default STDOUT). IMHO it's much cleaner and easier to understand if you use use FileHandle; STDOUT->autoflush(); This also prevents having to play with select() if you need to autoflush a non-default filehandle. HTH, Jenda =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ========== There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]