my @a1 = qw( A B ); my @a2 = qw( A B C D A D B A C ); foreach my $el(@a1){ my $count = grep /^$el$/, @a2; print "$el is in Array2 $count times\n"; }