in reply to Script Hanging w/Data::Dumper and Text::CSV_XS
#!perl -w use strict; use IO::Scalar; use Text::CSV_XS; my $csv = Text::CSV_XS->new( {binary=>1} ); my $fh = new IO::Scalar; my $str = qq{aa,"b\nb","c,c",7\ndd,ee,ff,8}; $fh->open(\$str); while (my $cols = getline($fh)) { print "<$_>" for @$cols; print "\n"; } sub getline { my $cols = $csv->getline($_[0]); if (!$cols) { die $! if $!; return undef; } return (@$cols) ? $cols : undef; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Text::CSV_XS to parse a string
by saberworks (Curate) on Nov 11, 2004 at 01:06 UTC |