use strict; use warnings; my $one = "AGCTGATCGAGCTAGTACCCTAGCTC"; my $two = "AGATGATCGAGCTAGTACCCTATCTC"; # Diffs here ^ ^ my $diff = $one ^ $two; my @posns = (); push @posns, pos $diff while $diff =~ m{[^\0]}g; print qq{Differences, 1-based counting, at - @posns\n}; @posns = (); push @posns, pos $diff while $diff =~ m{(?=[^\0])}g; print qq{Differences, 0-based counting, at - @posns\n};