It's not a backreference problem. Characters from your last group are matched by .+
but not by your optional capturing group, thus this last group matches an empty string.
The problem is that you use a greedy quantifier that matches all possible characters before. Since your last group is optional, .+
matches all until the end of the line, the regex engine doesn't need to backtrack to match your string (and doesn't need to find "indeed").
A simple way to solve the problem is to use a lazy quantifier instead and an end anchor to force to go to the end of the line (because a lazy quantifier stops as soon as possible):
m/^this.+(very).+?(indeed)?$/
note: if "indeed" aren't always the last characters of the string, you must add .*
before the $