Perl: Store column from Mysql-table in Perl-Hash -
I have problems with MySQL and Perl.
I am coding a web crawler and I want to save the Tudo-list in the MySQL table.
Now, at the beginning of the script, I want to load mySQL from MySQL in Pearl hash, so that I do not filter the URL again.
- The following is the structure:
The table "todo" - unique ID "todoid" - TODO-urls "todourl" < / Blockquote>
- ToDo hash in Pearl is like this:
My% todo = ();
$ VAR1 = 'http://www.example.com/661/';
How can I load all mysql-table URLs in my own hash?
You can use DBI, like Allen has suggested, but with less code:
$ todo = $ dbh- & gt; Select all_hashref ('select todoid, todoourl fROM todo', 'todoid'); As you can see, I did not use DBI's preparation, execution, fetch and finish because the
selectall_hashref method does all this for us.
View online documentation:
- ToDo hash in Pearl is like this:
Comments
Post a Comment