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

by
Jeremy Canfield |
Updated: October 01 2023
| 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