perl - get number of elements in an array
is there any way to get the number of elements an array has?
say i have @array = ("one","two","three","four","five","six") is there a possible way to get the number of how many elements there are from $array[0..$#array] and then assign it to a variable? |
Just use:
$numelements=@array; |
oh goodness, had no idea all I had to do was assign some scalar to it
thanks for the reply! |
in longhand you would explicitly request a scalar interpretation of it, e.g "$num = scalar @array". it's not needed, but does make it slightly clearer for when you can't be bothered to comment your own code.
|
All times are GMT -5. The time now is 01:25 AM. |