my $statement = qq( INSERT INTO dickens VALUES ($word, $Line{$word}) );
No, don't do that. Use placeholders instead:
my $sth = $dbh->prepare('INSERT INTO dickens VALUES(?, ?)'); # and then, as often as you want: $sth->execute($line, $count);
I guess the database looks something like this:
CREATE TABLE dickens ( word VARCHAR(30), line INTEGER, );
If that's the case, you can't store multiple line numbers in one row. In that case you have to make multiple rows with the same word, or change the database layout.
foreach $word ( @theseWords ) { my @lines = split m/ ,/, $Line{$word}; for (@lines){ $sth->execute($word, $_); } }
Of course it's better to store the line numbers as arrays in the first place.
In reply to Re: Inserting the line references in a text file
by moritz
in thread Inserting the line references in a text file
by Quicksilver
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |