Re: [問題] 特殊變數 $| 的用途

看板Perl作者 (人生太奇妙了 )時間14年前 (2011/08/24 21:20), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串2/2 (看更多)
※ 引述《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

08/31 17:18, , 1F
line buffer就是說以line為單位,把東西從buffer丟出來
08/31 17:18, 1F

08/31 17:18, , 2F
所以相對來說比較快出現你想要print的東西
08/31 17:18, 2F

09/05 23:32, , 3F
不然為了省IO時間,會等buffer滿了再一次丟出來
09/05 23:32, 3F
文章代碼(AID): #1ELFgbdz (Perl)
討論串 (同標題文章)
文章代碼(AID): #1ELFgbdz (Perl)