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

The problem is not with the regexp. The problem is that $_ only contains one line. See my earlier post in this discussion for more details.

Replies are listed 'Best First'.
Re^4: multiline regex: heredoc vs. reading file
by bowei_99 (Friar) on Jan 25, 2006 at 18:10 UTC
    OK, so I changed the while loop to contain the following, and still get the same thing -
    $_ .= <TEST>; if (m{ \w+\n .+ \w+ }msx) { print "reading file test: The line \n$_\nmatches.\n"; }
    I would think that
    a) $_ .= <TEST>; would be equivalent to your $text = <$test_fh>; line, and
    b) replacing \n with .+ utilizes the /s,

    correct?

      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.