FreeKB - Count values in an array in Perl
Count values in an array in Perl

Home > Search

Let's say you have an array that contains 4 values.

my @array = qw(value1 value2 value3 value4);


In this example, the $count variable will contain the number of elements in @array.

my $count = @array;


You can print the $count variable;

print $count;


Which will return 4, meaning there are 4 values in @array.



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 29e96 in the box below so that we can be sure you are a human.