my $count = scalar grep { $array1ref->[$_] eq $array2ref->[$_] } 0 .. $#$array1ref;