From: Eric Wilhelm <[EMAIL PROTECTED]>
> I've written some code before which uses the CSV.pm module (has this
> never appeared on CPAN?) But had to step-through the number of quotes
> and read-in some extra lines to get a full record (where linefeeds are
> embedded in fields.)
>
> That was a terribly memory hog, and entangled with some task-specific
> code (but I'm a better programmer now than I was two years ago.) So,
> I thought I would take a look at CPAN before I try to round-off this
> square wheel. From the looks of it, there isn't anything there for
> this.
>
> I looked at Text::CSV_XS and messed with Text::CSV::Simple, but both
> of these seem to want a record to be only on one line.
You should have read the Text::CSV_XS docs better and try it :-)
use IO::Handle;
use Text::CSV_XS;
my $csv = Text::CSV_XS->new({
'quote_char' => '"',
'escape_char' => '"',
'sep_char' => ',',
'binary' => 1
});
#open my $IN, '<', 'c:\temp\zkCSV.csv' or die "Can't open
zkCSV.csv\n";
my $i = 1;
#while (my $columns = $csv->getline($IN)) {
while (my $columns = $csv->getline(\*DATA)) {
last unless @$columns;
print "ROW", $i++,":\n";
for (@$columns) {
print qq{COL: "$_"\n};
}
print "\n";
}
__DATA__
"simple","and a long
long
field",15
"other","short this time", 48
! The
use IO::Handle;
is necessary !
Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery