揮発性のメモ2

http://d.hatena.ne.jp/iww/

出力をバッファリングさせない

出力先が名前付きパイプとかファイルとかだと、バッファリングされてしまうっぽい。
なので、バッファリングさせないようにする。

$ cat hoge.pl
#!/usr/bin/perl

open my $fh, "> hoge";
select((select($fh), $|=1)[0]);  # $fh をバッファリングさせない

while(<>){
    print $fh "$_";
}