此问题在此处已有答案:
Difference between &function and function() in perl [duplicate](2个答案)
八年前就关门了。
Perl中下面两行代码的区别是什么:
PopupMsg("Hello");
&PopupMsg("Hello");
...
sub PopupMsg
{
subroutines code here...
}
请注意,在某些情况下,我必须使用第一行,而在某些情况下,我必须使用第二行,否则我会得到一个错误。
2条答案
按热度按时间1hdlvixo1#
使用&符号
&
调用子例程是不好的做法。如果使用括号或将符号预声明为子例程名称,则调用将编译良好。当您将子例程作为数据项处理时(例如,获取对它的引用),&号是必需的。
guicsvcw2#
请参阅http://perldoc.perl.org/perlsub.html:
原型将在www.example.com中进一步说明http://perldoc.perl.org/perlsub.html#Prototypes。