Thinking about it, an answer can be a really multi-approach one for Perl's text manipulation capabilities are many, though it seems you don't want scores or substitution matrices evaluation it'd still be better to not reinvent the wheel -unless you're practicing a concept- and try to look at available
Sequence Alignment modules that can potentially provide this sort of task.
Providing samples of sequences, expected output, and your code-efforts would greatly enhance the response you'd receive from the beloved Monks...
Excellence is an Endeavor of Persistence.
Chance Favors a Prepared Mind.