With the following CSV file:#!/usr/bin/perl use strict; use warnings; use Text::CSV_XS; my $file = $ARGV[0]; my $xs = Text::CSV_XS->new({'strict' => 1,'auto_diag' => 2}); open(my $handle,$file); $xs->column_names(['one','two','three']); while(my $line = $xs->getline($handle)) { print Dumper($line)."\r\n"; } close($handle);
I receive the following output:$ cat test.csv this,is,a test,of,the csv,parser,logic
where rec 4 is a non-existent line below "csv,parser,logic". There are no extraneous line breaks, or extra line endings. My expectation would be that EOF would skip the strictness check, but this does not appear to be the case. This does not occur without the strict option enabled. Is there a canonical approach recommended for using strict => 1 in the manner outlined above? Thanks in advance.$ ./csv_test.pl test.csv $VAR1 = [ 'this', 'is', 'a' ]; $VAR1 = [ 'test', 'of', 'the' ]; $VAR1 = [ 'csv', 'parser', 'logic' ]; # CSV_XS ERROR: 2014 - ENF - Inconsistent number of fields @ rec 4 pos + 1
In reply to Text::CSV_XS - strict mode and EOF by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |