作者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
推 borisC:line buffer就是說以line為單位,把東西從buffer丟出來 08/31 17:18
→ borisC:所以相對來說比較快出現你想要print的東西 08/31 17:18
→ iFEELing:不然為了省IO時間,會等buffer滿了再一次丟出來 09/05 23:32