Array length in PERL

Hi experts,
How to get the length of an Array in PERL.
for eg., @Var having 5 elements.

regards
Anent

Set a variable $a=@testarray

$a will be the number of elements in the array.

:slight_smile:

hi deeboy,
Wow, its working fine.
Thanks a lot
Anent

print $#array;

The difference is that

$#array

is the index of the last element in the array, while

scalar(@array)

is the number of elements.

Impressive old thread revival skills, BTW.

Yea, thanks for digging up a nearly 7 year old thread! :mad: