作者TaipeiWind (人生太奇妙了 )
看板Perl
标题Re: [问题] 特殊变数 $| 的用途
时间Wed Aug 24 21:20:34 2011
※ 引述《clanguage (C语言)》之铭言:
: 请问一下 $| 这个特殊变数有什麽用咧?
: 我看书上写 the autoflush flag determines if line or block buffering
: should be used. if 0, it's block, if 1, it's line.
: 查了网页上的介绍
: if set to nonzero, forces a flush after every write or print
: When you want your pipes to be piping hot
: 看起来是 flush stream 用的。
: 但是用不用对使用者的影响是甚麽阿?
: 有没有人了解这个东东或是有人有具体的实例之类的?
: 感谢
我自己使用的经验是
如果设定成0的话 你程式print到screen的东西会累积几十行才真的print出来
设成1的话 每一行都会real time的print出来
我自己比较习惯设定成1 因为一些debug的information在跑程式的时候
比较看的到
--
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.160.248.146
1F:推 borisC:line buffer就是说以line为单位,把东西从buffer丢出来 08/31 17:18
2F:→ borisC:所以相对来说比较快出现你想要print的东西 08/31 17:18
3F:→ iFEELing:不然为了省IO时间,会等buffer满了再一次丢出来 09/05 23:32