AnomalousMonk said it all, but just to put it in other terms, you want your regex to stop at the first occurrence of the regex end delimiter (I mean the end of the pattern), rather that the last one.
So simply:
my $regex = '%17\{#MARKERS.*?MARKERS#}';
With the
? qualifier, the regex engine is no longer going to match as much as possible, i.e. up to the very last occurrence of the
MARKERS#} end delimiter, but will be happy to stop at the first one, which is what you need here.
Actually, when quantifying
. any character symbol, the
.* or the
.+ pattern is relatively rarely what you want, quite often
.*? and
.+? are better. But that's not a general rule, there also cases when you want to match up to the end of the last regex end delimiter.