in reply to Re^4: multiline regex: heredoc vs. reading file
in thread multiline regex: heredoc vs. reading file

Now, $_ contains two lines, but you need three with the data you showed. Also, $_ .= <TEST> could attempt to read past the end of the file, but you don't check for that.