for my $row (@{$sth->fetchall_arrayref}) { # note $row is an actual row, not a number my $h = $row->[0]; $Data{$h}{$tableFts{$table}[$_]} = $row->[$_] for 1 .. $#{$row}; }