# New Ticket Created by  H. Merijn Brand 
# Please include the string:  [perl #127358]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=127358 >


$ dump crnl.csv
[DUMP 0.6.01]

00000000  31 2C 32 2C 2C 22 34 22  2C 22 35 20 77 69 74 68    1,2,,"4","5 with
00000010  20 5C 72 5C 6E 0D 0A 20  65 6D 62 65 64 64 65 64     \r\n.. embedded
00000020  22 2C 36 0D 0A                                      ",6..

$ cat crnl.pl
use v6;
my $fh = open "crnl.csv", :r, :!chomp;
.perl.say for $fh.lines;

$ perl6 crnl.pl
"1,2,,\"4\",\"5 with \\r\\n\n"
" embedded\",6\n"

That first line should have been:
"1,2,,\"4\",\"5 with \\r\\n\r\n"

as the \r is part of the data, not of an EOL

I need an option to leave every new-line sequence unchanged.

The nl attribute for open won't work, as I cannot know in advance what the EOL 
sequence in the stream/file is and besides, CSV allows mixed EOL, so 
«1,2,,4\r\n1,2,3,\r1,,3,4\n» is completely valid CSV for Text::CSV

As callers to the parsing process are allowed to open an already opened file 
(an IO stream), this new :preserve-nl attribute (or whatever it will be 
implemented as), should be alterable *after* the stream has been opened, so it 
can be changed to local behavior inside the parsing proces.

Reply via email to