in reply to printing records in MySQL

start by understanding how a record set from a db query is represented by the Perl data structures. There are primarily two ways --

Each record can be either an array of columns or a hash with column-names as hash keys and column-values as the corresponding hash values.

But, that is only one record. Several records are treated as arrays.

So, a complete record set (be it of one record or multiple records) is an array of arrays (aoa) or an array of hashes (aoh).

Once you have the record set, loop through the array, deref the elements into the corresponding array elements or hash keys, and print the values.

If you get it a row at a time (as you are doing), do what dragonchild suggests. Put it in a while loop. If you bring it all at once, you have the entire structure anyway. Use HTML::Template and you have the aoh ref ready to feed to it... no further assembly required.