#!/usr/bin/perl use strict; use warnings; my $oldstring = 'ATTGC---AGTCCATGC------ATGC'; my $newstring = 'AT-TGC---AGTCCATGC--------ATGC'; my @oldstring= ($oldstring=~ /(-*)(?:A|C|G|T|$)/g); my @newstring= ($newstring=~ /(-*)(?:A|C|G|T|$)/g); my $pos= 0; for (my $i= 0; $i < @oldstring; ++$i) { if ( $oldstring[$i] ne $newstring[$i]) { print length($newstring[$i]) - length($oldstring[$i])," at position ",$pos,'-',$pos+length($oldstring[$i]),"\n"; } $pos+= length($oldstring[$i])+1; }