my $sth=$dbh->prepare($query); $sth->execute or die $DBI::errstr; my $array_of_hashes = $sth->fetchall_arrayref({}); for my $href (@$array_of_hashes) { # do something smart with $href }