I suspect you could still handle this without an external library. Complex regex aren't my forte, but I know this forum where that seems to be a pretty popular pasttime...
Something along the lines of:
$_ =~ s/some expression meaning a quoted comma/some placeholder/g;
@line = split(/\,/, $_);
#if the commas are needed
foreach my $line (@line){
$line =~ s/some placeholder/,/g;
}
or
@line = split(/some expression that only matches commas not within quo
+tes/, $_);
You're going to pay a bit of a performance penalty on the 2nd substitution or the more complex matching statement, but it's linear not exponential, so not too bad. Given what you've seen with Text::CSV, I'd wager it'll still be an improvement.
Perhaps I'm a purist, but I am loathe to pull in another module when the task can be accomplished without it. |