in reply to DBI with hash of arrays

I would like to minimize the amount of code lines

Please read The path to mastery.

I don't quite understand what you want your resulting data structure to look like, and I don't know what you want to do with it, so I fear your need to provide more information. For example when you talk about a hash, what should be the keys, what should be the values? Which values do you expect in the arrays?

But one thing I know: if you do a query, and use the results only as input for another query, using just a single query with a join over both tables is probably more efficient and results in less Perl code. If you need the results in a particular order, a GROUP BY or ORDER BY clause can help.