if($seq=~/^(U+)([I|O|P|B|M])/) { $part_to_change1=$1; $len1=length($part_to_change1); $char1=$2; substr($top, 0, $len1, ($char1 x $len1)); }