my $hash = $dbh->selectall_arrayref("SELECT id,name,age FROM foo", "id"); #### # ... my @rows; $sth->execute(); while (my $row = $sth->selectrow_hashref()) { push(@rows, { %$row }); # Force unique reference }