# This only works if NAME is the first column...or you # would have to change the "select *" to select # specific columns in a specific order my @columns = grep { $_ ne 'NAME' } @{$sth->{NAME_uc}}; $sth->bind_columns(\my $name, \@row{@columns}); ...then later push @names, $name; ...and $data->{"data_$i"} = { %row };