Many thanks for explaining how useful placeholders are to me, @roboticus
I have replaced code:
while (my $row = $csv->getline($fh)) { $prep = $db->prepare("INSERT INTO $table VALUES (\"" . joi +n('","', $csv->fields()) . "\")") or die "Cannot prepare database " . $db->errstr() +. "\n"; if (!$prep->execute()) { die "Failed to write row " . $db- +>errstr() . "\n"; } }
with the code that you have suggested to me, but the script produces another error:
DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at ./test.pl line 85, <$fh> line 2.and so on for every record of the file to be imported.
which makes no sense to me, as from my understanding when I use map { expr } list, it evaluates expr for every item in list, so it should update the list automatically, isn't that right?
In reply to Re^2: Use of uninitialized value in join or string
by domaniqs
in thread Use of uninitialized value in join or string
by domaniqs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |