FreeKB - Count the number of values in an array in Perl
Count the number of values in an array in Perl

Home > Search


Let's take for example the following array. In this example, there are 4 values in the array.

@fruit = qw(banana apple orange grapes);

 

The following can be used to create a variable that contains the number of elements in the array. In this example, the value of $size will be 4.

my $size = @fruit;

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments