in reply to Re^4: out of two strings which occurs first in a text
in thread out of two strings which occurs first in a text

It's not a question of greediness. "pat" matched, so the alternation was successful. "pat" can't possible match any more than it has, so that's the end of the alternation. Elements of alternations are tried in turn. Greediness would factor in if you had /pat(?:tern)?/.

If you wanted to get the longest first, sort the elements of the alternation.

my ($re) = map qr/$_/, join '|', map quotemeta, sort { length($b) <=> length($a) } @words;

Of course, that doesn't work for patterns that can match strings of various lengths.