加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Perl运算符:$| ;美元符号加上加号

发布时间:2020-12-15 21:31:07 所属栏目:大数据 来源:网络整理
导读:我正在开发一个已经发布的perl代码的新版本,并找到了一行: $|++; AFAIK,$|与管道有关,如in this link所述,我明白这一点,但我不知道(plus plus)是什么意思. 先谢谢你. 编辑:找到答案in this link: 简而言之:它强制在下一个语句之前打印(刷新)到控制台,以
我正在开发一个已经发布的perl代码的新版本,并找到了一行:
$|++;

AFAIK,$|与管道有关,如in this link所述,我明白这一点,但我不知道(plus plus)是什么意思.

先谢谢你.

编辑:找到答案in this link:

简而言之:它强制在下一个语句之前打印(刷新)到控制台,以防脚本太快.

Sometimes,if you put a print statement inside of a loop that runs really really quickly,you won’t see the output of your print statement until the program terminates. sometimes,you don’t even see the output at all. the solution to this problem is to “flush” the output buffer after each print statement; this can be performed in perl with the following command:

$|++;

[update]
as has been pointed out by r. schwartz,i’ve misspoken; the above command causes print to flush the buffer preceding the next output.

解决方法

$|默认为0;做$|因此将其增加到1.将其设置为非零可以启用当前选择的文件句柄的自动刷新,默认情况下为STDOUT,并且很少更改.

所以效果是确保print语句等立即输出.如果要输出到套接字等,这是有用的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读