更新时间:2022-05-08 21:41:19
Like codehead 说,你必须迭代数组索引而不是它的元素.与 C 风格的 for
循环相比,我更喜欢这个变体:
Like codehead said, you'd have to iterate over the array indices instead of its elements. I prefer this variant over the C-style for
loop:
for my $i (0 .. $#x) {
print "$i: $x[$i]
";
}