if($str=~/([ATCG])\.+$/) { $last_mapped_char=$1; $rightmost_position_of_letter = rindex($str, $last_mapped_char)+1; }