我的test.pl腳本如下。如何在命令行上將值傳遞給Perl子例程參數?
#!C:\Perl\bin\perl.exe
use strict;
use warnings;
sub printargs
{
print "@_\n";
}
&printargs("hello", "world"); # Example prints "hello world"
如果我用print($a, $b);
代替printargs("hello", "world");
。
如何通過 '你好', '世界' 到$ A,$ B,當我在命令行中運行perl的test.pl世界你好,謝謝。
您應該明智地省略'&&從'&printargs(...)'。你不需要它,並且使用'&'前綴子調用可能會產生你可能不期待的副作用。 – 2010-02-11 09:09:36