$ perl -Mstrict -Mwarnings -E ' my $ref = q{AATTTGGGCTACT}; my $qry = q{AAATTCGGCTACA}; my $xor = $ref ^ $qry; my @offsets; push @offsets, pos $xor while $xor =~ m{(?=[^\x00])}g; say join q{ }, map { ( $_ + 1 ) . substr $qry, $_, 1 } @offsets;' 3A 6C 13A $