gpt4 book ai didi

perl $|=1;这是什么?

转载 作者:行者123 更新时间:2023-12-02 10:12:15 25 4
gpt4 key购买 nike

我正在学习用 Perl 编写 CGI 应用程序 - Kevin Meltzer。布伦特·米哈尔斯基

书中的脚本大多以此开头:

#!"c:\strawberry\perl\bin\perl.exe" -wT
# sales.cgi
$|=1;
use strict;
use lib qw(.);

$|=1; 是什么行?如何间隔它,例如。 $| = 1;或 $ |= 1; ?为什么要严格使用; $|=1 之后; ?

谢谢

最佳答案

perlvar是你的 friend 。它记录了所有这些神秘的特殊变量。

$OUTPUT_AUTOFLUSH(又名 $|):

If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0 (regardless of whether the channel is really buffered by the system or not; $| tells you only whether you've asked Perl explicitly to flush after each write). STDOUT will typically be line buffered if output is to the terminal and block buffered otherwise. Setting this variable is useful primarily when you are outputting to a pipe or socket, such as when you are running a Perl program under rsh and want to see the output as it's happening. This has no effect on input buffering. See getc for that. See select on how to select the output channel. See also IO::Handle.

Mnemonic: when you want your pipes to be piping hot.

祝你编码愉快。

<小时/>

其他问题:

没有理由 use strict;之后 $| ,但程序员约定除外。 $|而其他特殊变量则不会受到这种方式的 strict 影响。间距也不重要——只需选择您的约定并保持一致即可。 (我更喜欢空格。)

关于perl $|=1;这是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6303515/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com