Are there any robust ways to grab records from a CSV file?
Yes, use Perl's native getline method (what you're calling when you use angle brackets on a filehandle).
To see if your discrepancy results from embedded newlines or simply from blank lines, you might try a histogram of commas seen per line.
my %lines_with_this_many_commas; while (<$csvfile>) { my $comma_count = tr/,/,/; $lines_with_this_many_commas{$comma_count}++; } print "Perl's getline counted $. lines\n"; print "with the following incidence of commas:\n"; my $PRINTF = "%10s %30s\n"; printf $PRINTF, 'Commas', 'Lines with this many commas'; for my $n (sort {$a<=>$b} keys %lines_with_this_many_commas) { printf $PRINTF, $n, $lines_with_this_many_commas{$n}; }
In reply to Re: A problem with Text::CSV
by Narveson
in thread A problem with Text::CSV
by lihao
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |