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 getc for that. (Mnemonic: when you want your pipes to be piping hot.)作者: ldorothy 時間: 2009-06-19 14:03
謝謝兩位,我先弄弄作者: ldorothy 時間: 2009-06-19 15:54
用了$|,可是還不是我想要的結(jié)果。當(dāng)下面的程序在執(zhí)行中,被強(qiáng)制kill了,是否f.txt文件里什么內(nèi)容都沒有。
#!/usr/bin/perl -w
open HANDLE, ">>f.txt";
$num = 1;
$| = 1;
while ($num < 10)
{
print HANDLE "($num)'s\n";
$num++;
sleep 1;
}
close HANDLE;作者: Perl_Er 時間: 2009-06-19 16:06
use IO::File;