in reply to Unable to detect error from Text::CSV
The error is from perl itself, not from the CSV parser. It happens deep in the bowels of the code:
sv_setiv (*svp, SvIV (*svp));
because you specified types, and an empty string is not a number:
$ perl -wE'my $int = 1 + ""' Argument "" isn't numeric in addition (+) at -e line 1.
It is (very) easy to alter the code to make IV and NV types forced return of 0 or 0.0 on empty and undef fields, but that would cause backward incompatibilities and I doubt if it warrants a new attribute/options. Besides, you can already guard your own code against this:
$ perl -wE'no warnings "numeric";my $int = 1 + ""' $
Or in your own script:
while (my $colref = eval { no warnings "numeric"; $csv->getline_hr ($f +h)}) {
Also note that perl does the richt thing anyway:
say "$_ $names->[$_]\t$colref->{$names->[$_]}" for grep { $types->[$_] == Text::CSV_XS::IV } 0 .. $#$types; -> End of line processing Argument "" isn't numeric in subroutine entry at /pro/3gl/CPAN/Text-CS +V_XS/blib/lib/Text/CSV_XS.pm line 871, <$fh> line 3. New line status: error_input: error_diag: 2 Volume.serialno 3643411828 3 vtype 4 7 skip002 1 8 skip003 0 9 skip004 260 12 skip005 0 13 skip006 2147483648 14 Thumbnail.width 400 15 Thumbnail.height 400 16 skip007 0 17 skip008 0 18 skip009 3 19 skip010 24 20 skip011 0 21 skip012 172 22 skip013 200 23 skip014 518 24 skip015 3603 29 skip017 0
|
|---|