in reply to Help on array element counting

Calling your array @fruits,

for my $fruit (qw{MANGO APPLES}) { print $fruit, ' => ', scalar( grep { $fruit eq $_ } @fruits), $/; }
that works because grep in scalar context gives you the count.

The other and sometimes better way is to count them into a hash,

my %fruit_count; $fruit_count{$_}++ for @fruits; for (qw{MANGO APPLES}) { print $_, ' => ', $fruit_count{$_}, $/; }
That is better when @fruits is not being updated and you need counts for many different items.

After Compline,
Zaxo