--- kosta <[EMAIL PROTECTED]> wrote:
> Question: What is "flush"? and how can a filehandle be flushed? I saw
> such a phrase while looking for info about file locking.
Most filehandles are buffered by default, which means they don't bother
doing IO to the disk/socket/whatever until they have a bufferload of
bytes to send all at once, which is usually a big peformance win.
If you would rather have every byte sent down that pipeline without
buffering, you can set a filehandle as unbuffered with the following:
my prev = select FH; # stores the previous default filehandle,
# and set FH as the new default
$| = 1; # any true for $| unbuffers the current default filehandle
select $prev; # restores the previous default
Now that filehandle won't buffer.
Also, look at perldoc FileHandle for a filenadle class (which has
several benefits, including a more readable and concise
$fh->autoflush(1) syntax).
Since I usually want STDOUT as my default, I tend to compress the above
code to one line as a sort of block-of-thought:
select FH; $|=1; select STDOUT; # autoflush FH
Paul
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/