1. Perl
  2. Array
  3. here

Get the number of elements in the array

To get the number of elements in an array , array scalar Evaluate in context.

my $length = @nums;

The number of elements in an array is also called the length of the array or the number of elements in the array.

In Perl, there is no such thing as a function to get the length, you can get the number of elements in an array by evaluating the array in a scalar context.

The easiest way is to assign it to a scalar variable as described above. That way, @nums will be evaluated in the scalar context and $length will be assigned the number of elements in the array.

Related Informatrion