I had moved from Text::CSV to the XS version because of a problem of newline inside data Text::CSV parsing when data contains newline
Text::CSV_XS removes all the escape chars in the data ( I am using linux with perl 5.8.8 ) This is the sample code (below)
I expect that the attribute on the 3 row should be \N after escaping 1 \ but Text::CSV_XS removes both the \
use strict;
use warnings;
use Text::CSV_XS;
my $csv = Text::CSV_XS->new({
binary => 1,
eol => "\n",
quote_char => '"',
escape_char => '\\',
auto_diag => 2,
allow_loose_escapes => 1,
}) or die "Can't create CSV parser";
while( my $row = $csv->getline(\*DATA) ) {
print join(" ",@{$row})."\n";
}
__DATA__
ata,atb,atc
1a,"1b
1b-continued",1c
\\N,2b,2c
This is the output
ata atb atc
1a 1b
1b-continued 1c
N 2b 2c
Use
allow_unquoted_escape => 1
(available since version 0.95).