$sql = "select * from table limit 10"; $sth = $db->prepare($sql); $sth->execute() or die "SQL Error: $DBI::errstr\n"; my $rows = $sth->fetchall_arrayref({ Slice => {}}); foreach my $row ( @$rows ) { print $row->{'id'}, "\n"; }