in reply to perl: comparing words in the arrays

choroba has provided a solution giving the number of mismatches but if you also want their positions (as I think you say) then a regex and pos might help. This code gives 1-based positions, just subtract 1 in the regex code block if you need 0-based.

$ perl -Mstrict -Mwarnings -E ' my @seqs = qw{ ATGC TGCT GCTA CTAA TAAC }; my $match = q{GTCA}; foreach my $seq ( @seqs ) { my @posns; my $diff = $seq ^ $match; my $nMismatches = () = $diff =~ m{([^\0])(?{ push @posns, pos $dif +f })}g; say qq{$seq : $match -> $nMismatches at @posns}; }' ATGC : GTCA -> 3 at 1 3 4 TGCT : GTCA -> 3 at 1 2 4 GCTA : GTCA -> 2 at 2 3 CTAA : GTCA -> 2 at 1 3 TAAC : GTCA -> 4 at 1 2 3 4 $

I hope this is helpful.

Cheers,

JohnGG