Is there a macperl monk in the monastery?
I've installed DBI and DBI::CSV on my mac to do some quick and dirty processing of files delimited with bars (i.e. "|"). Below is the test code, adapted from the docs, that is giving me trouble. The problem is that it returns only the first row of the productDB test file (containing the table fields) rather than the whole table. Can anyone spot the problem? Having searched through the macperl mailing list archives I found only one unanswered posting with the same problem.
#!perl -w
use DBI;
use strict;
my $dbh = DBI->connect("DBI:CSV:csv_sep_char=|:f_dir=Hard Disk:develop
+ment")
or die "Cannot connect: " . $DBI::errstr;
$dbh->{'RaiseError'} = 1;
$dbh->{'csv_tables'}->{'productDB'} = { 'file' => 'productDB',
'col_names'=>["product_id","product","price","name","image_url
+","description","options"],
};
my $sth = $dbh->prepare("SELECT * FROM productDB");
$sth->execute() or die "Cannot execute: " . $sth->errstr();
my @row;
while (@row = $sth->fetchrow_array) {
print ("Row: @row\n");}
$sth->finish();
$dbh->disconnect;
Thanks,
Sergej