【发布时间】:2010-02-11 08:10:19
【问题描述】:
我的 test.pl 脚本如下。
#!C:\Perl\bin\perl.exe
use strict;
use warnings;
sub printargs
{
print "@_\n";
}
&printargs("hello", "world"); # Example prints "hello world"
如果我将printargs("hello", "world"); 替换为print($a, $b);。
当我在命令行运行 perl test.pl hello world 时,如何将 'hello' ,'world' 传递给 $a , $b,谢谢。
【问题讨论】:
-
您最好从
&printargs(...)中省略&。您不需要它,并且在子调用前加上&可能会产生您可能没想到的副作用。
标签: perl parameters subroutine