
"Edi" == Edi Weitz <edi@agharta.de> writes: Edi> On Tue, 13 Jul 2004 23:35:28 -0700, Jan Rychter <jan@rychter.com> Edi> wrote: I guess it is debatable whether the last "!" should be there. Perl doesn't behave that way, but I guess it _is_ an empty line, now that I think of it. And I wanted to get "!" instead of empty lines. So it actually makes more sense than Perl.
Edi> Hmmm, yes it seems to make more sense. On the other hand, I'm Edi> trying to be as close to Perl as possible. Do you see any pattern Edi> there? Any idea why Perl doesn't add the last exclamation mark? Uh, well, hmm. I've tried reading "man perlre", but the part about \z, \Z and multiline strings gave me a headache. I really have no idea why Perl doesn't treat the end of a string as an "$" in this case, because it certainly does so for other expressions (e.g. "^4$" _will_ match at the end of a multiline string ending in "...\n4"). I see no reason to treat a string ending in "\n$" (on UNIX) differently: "^$" should definitely match there, as a new line has begun, and ended, being empty. My suggestion would be to document this behavior. A brave soul could report this to the Perl people, but I seriously doubt they'd consider it a bug. It might be one of those DWIM things. --J.