carric has asked for the wisdom of the Perl Monks concerning the following question:
I have been looking for a good example for what I am trying to do, but I am finding it harder than I expected. I have a script that builds an array of words using regex.
What I would like to do is push this array into a MySQL table. The script iterates through a file, line by line, and finds several things per line. e.g.
Each line would be something like this:
Selling a boat for $100. Please call John Smith at 555-1234. My address is 123 Spring Lane, Springfield MO 12345.
So, lets say you have hundreds of lines like this and you want:
@array = (Smith, John, boat, $100, 123 Spring Lane, Springfield, MO, 12345);
I reinitialize the array for each line, so I have an array for the info I want for each "ad". I want to be able to push this into an "ads" table in a MySQL table, but I can't find a good example of specifically doing it with an array.. I got all the way to the VALUES part, and couldn't find a good recipe for the syntax. I was hoping it might be like this:
Thanks for your help in advance.$query = INSTERT INTO ads ("lname,fname,item,price,street,city,state,z +ip) VALUES (@array);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI and Inserting an Array
by The Mad Hatter (Priest) on Mar 12, 2004 at 00:24 UTC | |
|
Re: DBI and Inserting an Array
by krujos (Curate) on Mar 12, 2004 at 00:28 UTC | |
by carric (Beadle) on Mar 12, 2004 at 04:55 UTC |