# New Ticket Created by  Aleks-Daniel Jakimenko-Aleksejev 
# Please include the string:  [perl #132154]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=132154 >


This was noticed in this PR: https://github.com/rakudo/rakudo/pull/1171

Basically, slurp is changing \r\n to \n. This may seem like a reasonable thing, 
except that then it has to also change \r to \n.

However, replacing \r\n seems like a meaningless thing to do anyway. See 
https://docs.perl6.org/language/traps#Splitting_the_Input_Data_Into_Lines for 
some context.

Long story short, .lines is already splitting the text using all possible 
variants of a newline. There's no need to mangle the data in slurp.

For example, let's say you want to split the data strictly by \n. One way to do 
it is to call .lines on a Handle, then it works fine. But if it happens that 
you must slurp the whole thing, this is what you have to do:

‘foo’.IO.slurp(:bin).decode.split(“\n”)

Notice how we use :bin to prevent it from doing the decoding, only to call 
.decode later anyway. All that just because .slurp itself is doing unnecessary 
data mangling.

How to resolve this ticket:
Option 1: stop doing what we do now. For example, don't do \r\n → \n 
substitution if it's under “use v6.d”
Option 2: include \r and make sure it acts exactly like .lines.join(“\n”)

Reply via email to