简体   繁体   English

Perl中的BAREWORD和* BAREWORD有什么区别?

[英]What's the difference between BAREWORD and *BAREWORD in Perl?

my $childpid = open3(HIS_IN, HIS_OUT, HIS_ERR, $cmd, @args);

my $childpid = open3(*HIS_IN, *HIS_OUT, *HIS_ERR, $cmd, @args);

It seems the above both works for my application. 看来以上两者都适用于我的应用程序。

What's the difference between BAREWORD and *BAREWORD in Perl? Perl中的BAREWORD*BAREWORD什么区别?

The meaning of a bareword varies. 裸字的含义各不相同。 Most of the time, a bareword is a function call. 大多数情况下,裸字是函数调用。

sub foo { say "Hello"; }
foo;

Sometimes, it's a string literal. 有时,它是一个字符串文字。

$x{foo}    # $x{"foo"}

In yet other circumstances, it produces a typeglob. 在其他情况下,它会产生一个类型的颜色。

print STDOUT "foo";   # print { *STDOUT } "foo";

In this case, 在这种情况下,

open3(HIS_IN, HIS_OUT, HIS_ERR, ...)

is equivalent to 相当于

open3("HIS_IN", "HIS_OUT", "HIS_ERR", ...)

but open3 uses that string as the name of a glob in the caller's package, so the above is functionally equivalent to 但是open3使用该字符串作为调用者包中glob的名称,因此上面的函数等效于

open3(*HIS_IN, *IS_OUT, *HIS_ERR, ...)

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

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