in reply to substr is behaving differently with small vs large strings

Looks to me like the problem is that your editcontig function changes the length of the string...

$rawseq =~ s/9//g;
reduces the length of the string by 1 character... Maybe you should substitute a space or something?

Trek