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:

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -