Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
\R not working as (I'd have) expected on Windows Strawberry perlby stevieb (Canon) |
on Sep 26, 2015 at 17:35 UTC ( [id://1143108]=perlquestion: print w/replies, xml ) | Need Help?? |
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):
...on many variants of Unix, produces:
...which I expect. However, on Windows, it prints:
...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.
Back to
Seekers of Perl Wisdom
|
|