my @fruits = ('apple','orange','apple','orange'); my $num_apple = grep /^apple$/i, @fruits; print $num_apple."\n";