Yeah, that is a limitation of Text::CSV. I chose to stick with the OP's choice of module anyway, but of course I should have said something about that.
Makeshifts last the longest.
| [reply] |
It is not an insurmountable limitation. All that you have to do is, every time the line doesn't parse, accumulate it into a buffer, and then prepend it to the next line. That will handle embedded returns.
There is no reason that this piece of logic couldn't be built into Text::CSV. You could even name it getline to mirror what Text::CSV_XS does. But it isn't there so people tend to get this wrong.
Incidentally here it is, (untested):
sub Text::CSV::getline {
my $self = shift;
my $fh = shift;
my $line = "";
my $line_no;
while (<$fh>) {
$line_no ||= $.;
$line .= $_;
return if $self->parse($line);
}
if ($line) {
die "CSV parse error at line $line_no";
}
}
| [reply] [d/l] |
| [reply] |