The local $/ = '' notation sets the record separator to "paragraph mode," where blank lines separate paragraphs. Thus, Group #1, Group #2 and Groups Combined will be read in one chunk. The regex /Combined/ is attempting to match the last group. When matched, the regex /FRUITS (.+)/g captures the last part of each line that's past "FRUITS ", and those parts are passed to @fruit.