Hi Prakash, executing your script at the command line, I take an error: /tmp/perl $ perl csv.pl DBD::CSV::st execute failed: Error while reading file ./testtable.csv: Bad file descriptor at /usr/lib/perl5/site_perl/5.8.8/DBD/CSV.pm line 210, <GEN0> chunk 1. [for Statement "SELECT * FROM info"] at csv.pl line 11. execute: Error while reading file ./testtable.csv: Bad file descriptor at /usr/lib/perl5/site_perl/5.8.8/DBD/CSV.pm line 210, <GEN0> chunk 1.
It seems, that there is a bug in DBD::CSV v0.22, consider following posting: http://www.perlmonks.org/?node_id=673399 and this bug ticket: https://rt.cpan.org/Public/Bug/Display.html?id=33764 Regards Andon --- On Sat, 5/31/08, Prakash Prabhakar <[EMAIL PROTECTED]> wrote: > From: Prakash Prabhakar <[EMAIL PROTECTED]> > Subject: DBD::CSV: perl script to read CSV file does not work > To: dbi-users@perl.org > Date: Saturday, May 31, 2008, 3:41 AM > I am using the following code in my .cgi progam (compiling > with perl-5.8.6, > UNIX OS). It doesnt work. Could you please let me know what > could be wrong? > I do not get any warnings/error messages/expected output. > The .cgi and the > .csv are in the same directory. > > Thanks, > Prakash > > use warnings; > use DBI; > $dbh = DBI->connect("DBI:CSV:") > or die "Cannot connect: " . $DBI::errstr; > $dbh->{'csv_tables'}->{'info'} = { > 'file' => *'testtable.csv'*}; > $sth = $dbh->prepare("SELECT * FROM info") > or die "prepare: " . $dbh->errstr();; > $sth->execute() > or die "execute: " . $dbh->errstr(); > while (my $row = $sth->fetchrow_hashref) > { > print("Found result row: id = ", > $row->{'id'},", name = ", > $row->{'name'}); > } > $sth->finish(); > > to work with *testtable.csv* file that contains just this: > name,id > DSA,123 > > I even modified the .csv file to have: > "name","id" > "DS",123