in reply to Need a Method to add recursion to my regex

Untested:
if (my @matches = $sequence[1] =~ m/^(.*)$reg(.*)$/i) { @{ $aligned[$posCount] }[ 0 .. $numInsertionDeletes - 1 ] = @match +es; }