in reply to Re^2: formatting output from a mysql query in column format
in thread formatting output from a mysql query in column format

If I understand what you are trying to do - you are spinning your wheels too hard.

Let the perl modules do the work for you.

Here is what I think you are trying to get to:

# @array contains the field names (You call them 'labels') . # OK - so I assume they are also the field names, and we will use the +m as labels. my $counter = 0; while ( my $r = $sth->fetchrow_hashref() ) { $counter ++; print " ---- $counter ------\n"; for my $fieldname (@array){ print " $fieldname:\t" . $r->{$fieldname} . "\n"; } }
(Untested)

            "XML is like violence: if it doesn't solve your problem, use more."