Subject: | How do you detect a parsing error on the last line when using getline? |
getline returns undef on failure but also at eof. Thus if the last line has a parsing error, a check such as:
while (my $row = $csv->getline(...)) {
...
}
$csv->eof or $csv->error_diag
doesn't have the desired effect.
What's a robust and reasonable way to check for an error state when using getline? The following seems to work, but I'm not sure it's a good solution:
unless ($csv->eof and ($csv->error_diag == 0 or $csv->error_diag == 2012)) {
$csv->error_diag;
}
Thoughts?