in reply to DBI and fetching data
Have a look at our Tutorials. Check out especially DBI Recipes at the section "Getting a list of lists".
In addition to solving your specific problem, you may find more valuable ways of dealing with your data.
In Section
Seekers of Perl Wisdom