Subject: | Text::CSV_PP incorrectly handles "0" fields under 'allow_whitespace=>1' |
Date: | Mon, 27 Jan 2014 12:31:48 -0500 |
To: | bug-Text-CSV [...] rt.cpan.org |
From: | Fulko Hew <fulko.hew [...] gmail.com> |
There is a difference in the XS version versus the PP version when you
have the 'allow_whitespace' enabled.
Under some conditions, a field containing "0" is greedily attached to the
preceding field.
Disabling the whitespace option (under PP version) _can_ correct the
behavior
However the XS version works correctly both with and without the whitespace
option.
Module allow_whitespace Go/nogo
====== ================ =======
CSV_PP 1 FAILS
CSV_PP 0 ok
CSV_XS 1 ok
CSV_XS 0 ok
A simple test case follows...
#!/usr/bin/perl
use Text::CSV_PP;
use Data::Dumper;
my $fh = *DATA;
my $csv = Text::CSV_PP->new ( { allow_whitespace => 1 } ); # this fails
#my $csv = Text::CSV_PP->new (); # this works
$csv->column_names($csv->getline($fh));
my $hr = $csv->getline_hr($fh);
print Dumper(\$hr);
my $a = $hr->{name1};
my $b = $hr->{name3};
print "'$a', '$b'\n";
__DATA__
"name1","name2","name3"
"value1","0","value3"