Subject: | Text::CSV_PP mishandles double quotes when quote_char=undef |
Date: | Tue, 17 Nov 2015 22:18:55 +0000 |
To: | "bug-Text-CSV [...] rt.cpan.org" <bug-Text-CSV [...] rt.cpan.org> |
From: | Kevin Broadey <kevin.broadey [...] ptti.co.uk> |
#!/usr/bin/perl
#
# File: csvtest.pl
#
# Call with PERL_TEXT_CSV='Text::CSV_XS' or 'Text::CSV_PP'
# to force the backend module.
use strict;
use warnings;
use Text::CSV;
print "backend = ", Text::CSV->backend, "\n";
my $csv = Text::CSV->new ( { quote_char=>undef } )
or die "Cannot use Text::CSV: ".Text::CSV->error_diag()."\n";
print "escape_char=<", ($csv->escape_char || 'undef'), ">\n";
$csv->print(\*STDOUT, [ 'space here', '"quoted"', '"quoted and spaces"' ]);
---------------------------------------------------------------------------
$ PERL_TEXT_CSV='Text::CSV_PP' ./csvtest.pl
backend = Text::CSV_PP
escape_char=<">
space here,"quoted","quoted and spaces"
---------------------------------------------------------------------------
$ PERL_TEXT_CSV='Text::CSV_XS' ./csvtest.pl
backend = Text::CSV_XS
escape_char=<">
space here,""quoted"",""quoted and spaces""
---------------------------------------------------------------------------
This is with Text::CSV 1.33 and Text::CSV_XS 1.20 and Perl 5.18.
The behaviour with Text::CSV_XS seems consistent with the POD:-
"If you change the default quote_char without changing the default escape_char, the escape_char will still be the quote mark.”
Note that if I set escape_char to undef then I get the same behaviour (as exhibited by CSV_PP here) with CSV_XS too.
--
Kevin Broadey