Subject: | "string" method of CSV_PP issue |
Date: | Wed, 22 Apr 2009 09:52:46 -0400 |
To: | bug-Text-CSV [...] rt.cpan.org |
From: | Patrick Paskvan <patrick.paskvan [...] gmail.com> |
First of all, thanks for this fantastic module. On our production
systems recently upgraded to:
Text::CSV 1.11
Text::CSV_PP 1.19
No Text::CSV_XS
On our dev system, we have:
Text::CSV 1.06
Text::CSV_PP 1.14
Text::CSV_XS 0.52
Up until a week ago, we were using the old-style Text::CSV module,
with neither of these backends. A few of our scripts use the "string"
method, and after the upgrade we noticed that the "string" method was
generating an exception in production, but not in dev:
Can't use string (<CONTENTS OF LINE>) as a SCALAR ref while "strict
refs" in use at /usr/share/perl5/Text/CSV_PP.pm line 204.
It appears that the "string" method of Text::CSV_PP does not work in
either of the above versions. Works as expected with Text::CSV_XS.
This script demonstrates the problem in either of our systems:
#!/usr/bin/perl
BEGIN { $ENV{PERL_TEXT_CSV} = 0 }; # force PP parser
use Text::CSV;
my $data = "this,is,some,csv,data\n";
my $csv = Text::CSV->new;
$csv->parse($data);
print $csv->string;
If the environment variable is set to 1 or 2 on our dev system, the
line is printed as expected. I haven't looked into this in detail,
but a quick browse of Text::CSV_PP:
*string = \&_string;
sub _string {
defined $_[0]->{_STRING} ? ${ $_[0]->{_STRING} } : undef;
}
Is there a case where "_STRING" is not a scalar? On the surface, it
would seem that the implementation would work as:
*string = \&_string;
sub _string {
$_[0]->{_STRING};
}
Our current workaround is to violate the interface and access
"_STRING" directly.
Thanks for your help,
Pat