my ($, $, $real-care-about-it) = 1, 2, 3;
say $real-care-about-it;
# => 結果:
# 3
my ($head, *@tail) = 4, 5, 6, 7, 8, 9; # 使用 slurpy,只要尾巴
# => 結果:
# $head -> 4
# @tail -> 5,6,7,8,9
# 副程式只要前兩個參數值
sub just_first_two(@array [$first, $second, *@rest]) {
say "First two: $first, $second, All: @array[]";
}
just_first_two(@tail);
# => 結果:
# First two: 5, 6, All: 5 6 7 8 9
# 連陣列都匿名,省得麻煩。XD
sub anoy_arry(@ [$first, *@rest]) {
say "$first";
}
anoy_arry(@tail);
# => 結果:
# 5
以上作法,適用於 my 和參數列。
