对于Perl 6,在其Parrot时代有几个答案,但它们似乎目前无法正常工作:
This is Rakudo version 2017.04.3 built on MoarVM version 2017.04-53-g66c6dda implementing Perl 6.c.
Does perl6 enable “autoflush” by default?的答案说它是默认启用的(但是那是2011年)。
这是我正在玩的程序:
$*ERR.say: "1. This is an error";
$*OUT.say: "2. This is standard out";
及其输出,这是一个不幸的命令:
2. This is standard out
1. This is an error
所以也许我需要打开它。有一个How could I disable autoflush?提到了
autoflush
方法:$*ERR.autoflush = True;
$*ERR.say: "1. This is an error";
$*OUT.say: "2. This is standard out";
但这不起作用:
No such method 'autoflush' for invocant of type 'IO::Handle'
我想我可以通过使我的IO类在每次输出后刷新来伪造自己。就其值(value)而言,正是由于缺乏此功能,我才无法将Perl 6用于今天的特定任务。
作为第二个问题,为什么Perl 6现在不具备此功能,尤其是当它看起来像以前那样拥有它时?您如何说服Perl 5的人,这不是问题?
最佳答案
当您问这个问题时,这可能还没有奏效,但是:
$*ERR.out-buffer = False;
$*ERR.say: "1. This is an error";
$*OUT.say: "2. This is standard out";
很难找到它,但是记录在案的here。
在Rakudo Star 2017.10中为我工作。
关于io - 如何自动刷新Perl 6文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44987540/