在 Perl 中查找數組的大小 - Find size of an array in Perl

問題:

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章