in reply to /m pattern matching modifier

for me the last pattern match should be GTT.

You only match once. How does "last" fit in? Perhaps you mean you expect the match operator to match as late as possible? If so, that's wrong; it matches as early as possible.

Add a leading (?s:.*) to make it match as late as possible.

"AAC\nGTT" =~ /(?s:.*)^.*$/m;