简体   繁体   English

STDOUT->autoflush(1) 在 Perl 中做什么?

[英]what does STDOUT->autoflush(1) do in Perl?

I've found a variety of information regarding autoflushing in Perl, but can't find any mention of a line formatted exactly like this:我在 Perl 中找到了有关自动刷新的各种信息,但找不到任何提及格式如下的行:

STDOUT->autoflush(1);

This is included in a program I'm analyzing, and I want to understand better what it does.这包含在我正在分析的程序中,我想更好地了解它的作用。 There is also this at the beginning of the program:程序开头也有这个:

use IO::Handle;

...which I think might be related, but it also doesn't mention this method in its documentation. ...我认为这可能是相关的,但它也没有在其文档中提到这种方法。

The method is listed in IO::Handle which you noticed该方法列入IO ::句柄,你注意到了

... $io->autoflush ( [BOOL] ) $| ...

whereby $|其中$| is set/unset, and it sends you to $|设置/取消设置,并将您发送到$| in perlvar for explanation在 perlvar 中进行解释

If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel.如果设置为非零,则在当前选定的输出通道上每次写入或打印后立即强制刷新。

As of v5.14 you don't have to use IO::Handle for this as IO::File is require d when needed. 从 v5.14 开始,您不必为此use IO::Handle ,因为IO::Filerequire时是必需的。

This method is special in that it turns autoflush on even without value supplied,这种方法的特殊之处在于即使没有提供值,它也会打开自动刷新,

$io->autoflush;  # turned on ($| gets set)

while other related ones don't change the current value when called without argument.而其他相关的在不带参数的情况下调用时不会更改当前值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM