I'm trying to read in a CSV data file using Text::CSV::Slurp. It's not working, and my code is so close to the code in Slurp's own example, that I suspect I might have stumbled into some odd configuration problem. Ideas?
In the following test file:
use strict;
use Text::CSV::Slurp;
use vars qw($file $data);
$file = "/orion-reqs/SaferHtml/CradleCSV/2012_03_30/Doc_Sections_SAFER
+_Group_Trace.csv";
$data = Text::CSV::Slurp->load(file => $file);
1
$data is an empty array. Going into the debugger, I find that the file is opened correctly, and the header is read. On the first line of data, Slurp calls
$csv->getline_hr($io)
Single step shows that this goes into Text::CSV::AUTOLOAD. That routine expects a method-name that starts with an underscore, which
getline_hr doesn't.
my $attr = $Text::CSV::AUTOLOAD; # bound to 'Text::CSV::getline_
+hr'
$attr =~ s/.*:://; # Now it's just 'getline_hr'
return unless $attr =~ /^_/; # returns with no value
FWIW, my
%INC
DB<11> x \%INC
0 HASH(0x98c4780)
'AutoLoader.pm' => '/usr/share/perl5/AutoLoader.pm'
'Carp.pm' => '/usr/share/perl5/Carp.pm'
'Config.pm' => '/usr/lib/perl5/Config.pm'
'Config_git.pl' => '/usr/lib/perl5/Config_git.pl'
'Config_heavy.pl' => '/usr/lib/perl5/Config_heavy.pl'
'DynaLoader.pm' => '/usr/lib/perl5/DynaLoader.pm'
'Exporter.pm' => '/usr/share/perl5/Exporter.pm'
'IO.pm' => '/usr/lib/perl5/IO.pm'
'IO/Handle.pm' => '/usr/lib/perl5/IO/Handle.pm'
'SelectSaver.pm' => '/usr/share/perl5/SelectSaver.pm'
'Symbol.pm' => '/usr/share/perl5/Symbol.pm'
'Term/Cap.pm' => '/usr/share/perl5/Term/Cap.pm'
'Term/ReadLine.pm' => '/usr/share/perl5/Term/ReadLine.pm'
'Text/CSV.pm' => '/home/dthroop/lib/perl/Text/CSV.pm'
'Text/CSV/Slurp.pm' => '/usr/local/share/perl5/Text/CSV/Slurp.pm'
'Text/CSV_XS.pm' => '/usr/lib/perl5/Text/CSV_XS.pm'
'XSLoader.pm' => '/usr/share/perl5/XSLoader.pm'
'dumpvar.pl' => '/usr/share/perl5/dumpvar.pl'
'perl5db.pl' => '/usr/share/perl5/perl5db.pl'
'strict.pm' => '/usr/share/perl5/strict.pm'
'vars.pm' => '/usr/share/perl5/vars.pm'
'warnings.pm' => '/usr/share/perl5/warnings.pm'
'warnings/register.pm' => '/usr/share/perl5/warnings/register.pm'
and what the args to the AUTOLOAD look like:
DB<16> x @_
0 Text::CSV=HASH(0x8ee2f90)
'_AHEAD' => undef
'_BOUND_COLUMNS' => undef
'_CACHE' => "\"\",\cA\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\
+c@\c@\c@\c@\c@\c@\cA\c@\c@\c@\c@\c@\cA"
'_COLUMN_NAMES' => undef
'_EOF' => ''
'_FFLAGS' => undef
'_FIELDS' => undef
'_MODULE' => 'Text::CSV_XS'
'_STATUS' => undef
'_STRING' => undef
'allow_loose_escapes' => 0
'allow_loose_quotes' => 0
'allow_whitespace' => 0
'always_quote' => 0
'auto_diag' => 0
'binary' => 1
'blank_is_undef' => 0
'empty_is_undef' => 0
'eol' => ''
'escape_char' => '"'
'keep_meta_info' => 0
'quote_char' => '"'
'quote_null' => 1
'quote_space' => 1
'sep_char' => ','
'types' => undef
'verbatim' => 0
1 IO::Handle=GLOB(0x8cb42e8)
-> *Symbol::GEN0
FileHandle({*Symbol::GEN0}) => fileno(6)
Does something look fishy?