問題:
I seem to have come across several different ways to find the size of an array.我似乎遇到過幾種不同的方法來查找數組的大小。 What is the difference between these three methods?這三種方法有什麼區別?
my @arr = (2);
print scalar @arr; # First way to print array size
print $#arr; # Second way to print array size
my $arrSize = @arr;
print $arrSize; # Third way to print array size
解決方案:
參考一: https://stackoom.com/question/V4qd參考二: Find size of an array in Perl