stevieb has asked for the wisdom of the Perl Monks concerning the following question:
I'm revisiting line endings on both Windows and Linux, and found something that I'm not sure whether it's a bug or if I've overlooked something.
This is in relation to the \R match character in perlrebackslash.
Using this code (note that win.txt is definitely a Windows-ending file):
perl -nE '/(\R)/; say (unpack "H*", $1);' win.txt
...on many variants of Unix, produces:
0d0a
...which I expect. However, on Windows, it prints:
0a
...on literally the exact same file. In fact, I've even set up a VirtualBox shared directory between a Windows VM and a Linux host, and put the file there, as well as testing on a copy. The results are the same.
I've tested perl v5.18 and 5.22 on nix, and Strawberry v5.22 on Windows.
Shouldn't Windows perl also print 0d0a or am I missing something? If this isn't the correct behaviour, could I get one of our Monks who use ActiveState perl test as well?
Update: note that interestingly, I get the same result (0a on win and 0d0a on nix) when I change the regex to /(\s+$)/, so if this is a problem, it isn't only related to \R. Also, on Windows, /\r\n/ does match.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: \R not working as (I) expect on Windows Strawberry perl
by choroba (Cardinal) on Sep 26, 2015 at 17:53 UTC | |
by Anonymous Monk on Sep 26, 2015 at 21:17 UTC | |
by stevieb (Canon) on Sep 26, 2015 at 18:00 UTC |