in reply to advice perl and mysql

Mysql has a my.cnf file that tells mysql how much of your resources to use when executing various types of queries. It ships with quite frugal settings. If you give it more resources (appropriate to your schema) it will often run much faster, often order of magnitude faster.

Even fixing/tweaking that you still have the problem that your queries are glacial. Try:

mysql>EXPLAIN SELECT.......

Databases are really only fast if you use their power to index. If the DB can not find an appropriate index to use it is forced to iterate through your data. I suspect you don't have the right indexes.

Nobody can really give you much other advice unless you become more specific about what the task is, what your schema is, and what you slow query actually looks like.