On 28 January 2012 19:30, Lukas Mai <l.mai@web.de> wrote: > On 2012-01-28 demerphq wrote: > >> You say that you consider "\n" to contain only one line. >> >> But what about "\nfoo". Does it contain one or two lines? Do you >> expect ^ to match after the \n in "\nfoo"? If you do then do you not >> agree there is an inconsistency about it not matching after the \n in >> "\n"? > > "\nfoo" contains 1.5 lines, i.e. one complete (but empty) line and one > incomplete (unterminated) line. > "\nfoo" =~ /^foo/m should match, yes. > I don't think there's an inconsistency because \n is only the beginning > of a line if more text follows. That is, my model of /^/m > is /(?:\A|(?<=\n)(?!\z))/. And the docs agree with you, perlre says this: You may, however, wish to treat a string as a multi-line buffer, such that the "^" will match after any newline within the string (except if the newline is the last character in the string), and "$" will match before any newline. Though I do wonder if the "except if the newline is the last character of the string" was a special case added later. >> Because to me that is the exact same thing as expecting /.*/ to match >> at the end of the string in "\n". >> >> So really the bug here is in ^ not in .* > > That doesn't match my intuitive understanding of "beginning of line". It is sort of a lawyers point I guess. To me the definition (start of string or immediately after a newline) would match up with expecting /.*/ to match twice against "\n". Anyway, it sounds like the ANCH_MBOL optimization is buggy, so do we turn it off or try to fix it somehow... cheers, Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"Thread Previous | Thread Next