Use the array in scalar context to get the size (number of elements) of the array. To force an array to be evaluated in scalar context, use the scalar operator.

Example:print "Size of array is " . scalar @array;

IMPORTANT! Please notice that this method ONLY works with arrays, it doesn't work with lists; if you evaluate a list in scalar context it will return the value of the last element of the list (like in the C language)