Subject: | mis-handling of allow_loose_quotes? |
Date: | Thu, 28 May 2015 16:29:15 -0400 |
To: | bug-Text-CSV_XS [...] rt.cpan.org |
From: | "Todd Eigenschink" <todd [...] xymmetrix.com> |
I ran into a situation with mid-field quotes in some data I was
parsing. It seems like *almost* exactly the sort of thing that
allow_loose_quotes was meant to handle.
I can see how this might be a corner case because the the first quote
character is actually the first character of the field, but it was
still surprising.
If you don't think it's a bug, so be it; I fixed it in my code by
setting quote_char to an apostrophe (commented out in the
example). See below.
Thanks for all your work; I use Text::CSV_XS almost daily!
----------------------------------------------------------------------
#!/usr/bin/perl
use Text::CSV_XS;
use Data::Dumper;
my $csv = Text::CSV_XS->new({sep_char => '|',
allow_loose_quotes => 1,
#quote_char => "'",
auto_diag => 1});
my $string = <<EOF
Field One|"d" Parcela #14 Barcelona|Field Three
EOF
;
$csv->parse($string);
my @f = $csv->fields();
print Dumper(\@f);
----------------------------------------------------------------------
Todd
--
Todd Eigenschink Xymmetrix, LLC
todd@xymmetrix.com http://www.xymmetrix.com/
Non ex transverso sed deorsum 260-407-1584