while (my $row = $sth->fetchrow_arrayref()) { # arrayref, not hash my $index = 0; print "$_ => ", $row->[$index++], "\t" for (@{$sth->{NAME}}); print "\n"; } # or the "C like" way while (my $row = $sth->fetchrow_arrayref()) { # arrayref, not hash for (my $index = 0; $index < $sth->{NUM_OF_FIELDS}; $index++) { print "$sth->{NAME}->[$index] => ", $row->[$index], "\t" } print "\n"; }