Bootstrap FreeKB - Perl (Scripting) - Count the number of elments in an list
Perl (Scripting) - Count the number of elments in an list

Updated:   |  Perl (Scripting) articles

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;

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


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