What is 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); 

All of the above seems to work for my application.

What is the difference between BAREWORD and *BAREWORD in Perl?

+7
source share
1 answer

The meaning of the word depends on the meaning. In most cases, this is a function call.

 sub foo { say "Hello"; } foo; 

This is sometimes a string literal.

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

In other circumstances, it creates a type glob.

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

In this case

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

equivalently

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

but open3 uses this string as the glob name in the caller's package, so the above is functionally equivalent

 open3(*HIS_IN, *IS_OUT, *HIS_ERR, ...) 
+8
source

All Articles