in reply to Re^3: Load CSV file into Database
in thread Load CSV file into Database
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"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Load CSV file into Database
by Aristotle (Chancellor) on Feb 01, 2005 at 04:49 UTC |