[moved to dbi-dev]
On Tue, Jun 11, 2002 at 10:00:03AM -0700, Jeff Zucker wrote:
> [EMAIL PROTECTED] wrote:
>
> > The application is written to use
> > DBD::CSV by default because it is pure perl and portable.
>
> Actually, though, DBD::CSV depends on Text::CSV_XS which requires
> compilation. DBD::AnyData, in CSV mode, works almost identically to
> DBD::CSV except that it uses pure perl instead of Text::CSV_XS to do the
> CSV parsing.
Actually, though, it's crossed my mind more than once to add the
core C code to parse a CSV record into the DBI. It should be tiny.
Patches welcome - if there's a worthwhile performance boost.
Speaking of which, I just took a look at the CSV read_fields code:
while ($str =~ m#$self->{regex}->[0]#g) {
$captured = $+;
$captured =~ s/$self->{regex}[1]/$self->{regex}[2]/g if $captured;
last if $captured && $captured eq "\n";
push(@fields,$captured);
};
I suspect it might run a little quicker this way (untested):
my $r = $self->{regex};
while ($str =~ m#$r->[0]#g) {
$captured = $+ and $captured =~ s/$r->[1]/$r->[2]/g;
...
};
(Could probably be made faster still if read_fields was dynamically
generated to have the current regex as a literal.)
Tim.