Text::CSV_XS does not properly handled a escaped sep_char if it is the
only item in a data field.
i.e. if sep_char => ',' and escape_char => '\\' and data is
'testing,\,,fields' data will show up as 4 columns instead of 3.
However, this is remedied if the escape_char is double used inside a
column with only the sep_char in it
i.e. if sep_char => ',' and escape_char => '\\' and data is
'testing,\\,,fields' data will show up properly as 3 columns.
Example script below:
#!/usr/bin/perl;
use Text::CSV_XS;
use Data::Dumper;
my $csv = Text::CSV_XS->new({quote_char => undef, escape_char => '\\',
sep_char => ','});
print "Properly escaped sep_char which should show up as 4 columns
showing up as 5 columns:\n";
$csv->parse('hello,wo\\,rld,\\,,testing');
print Dumper($csv->fields())."\n";
$csv->parse('hello,wo\\,rld,\\\\,,testing');
print "Double escaped sep_char showing up correctly as 4 columns:\n";
print Dumper($csv->fields());
__END__
From testing it makes no difference what escape and sep chars are, the
problem still exists.