There's more than one way to do things | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hi monks, apparently, /.*\z/ tests whether a string ends in a newline:
I find this very strange. In my opinion, this regular expression should always match. Every string, even "foo\n", has an end (\z), and since .* matches zero or more horizontal characters, it should always match the empty string before the end of the string. However, it doesn't, as you can see in the first one-liner. I found this RE in the code of Log::Handler by bloonix and I'm wondering why it works. I've tested it in perl versions 5.8.8, 5.005_03 and 5.9.4. Update: This perl bug is now fixed (see below). Thanks to demerphq. In reply to Strange regex to test for newlines: /.*\z/ by betterworld
|
|