while (my $row = $sth->fetchrow_hashref()) { print map( { "$_ => $row->{$_}\t"} @{$sth->{NAME}}), "\n"; } #or while (my $row = $sth->fetchrow_hashref()) { for (@{$sth->{NAME}}) { print "$_ => $row->{$_}\t"; } print "\n"; }