sub func($\@\%\%){
$arg1 = shift ;
@arg2 = @{(shift)};
%arg3 = %{(shift)};
%arg4 = %{(shift)};
print "\$arg1:", $arg1,"\n";
print "\@arg2:@arg2\n";
print "\%arg3:",%arg3,"\n";
for $ele (%arg4){
print $ele." ";
}
}
@arr = (1 .. 19);
%hash =(
k1 => "v1",
k2 => "v2",
);
%hash2 =(
k12 => "v12",
k22 => "v22",
);
func("Hello world.",@arr,%hash,%hash2);
#切記 : 參數不可為匿名陣列或匿名雜湊 否則會出現意外結果
#輸出結果:
$arg1:Hello world.
@arg2:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
%arg3:k2v2k1v1
k22 v22 k12 v12
沒有留言:
張貼留言