my $rows = $dbh->selectall_arrayref("SELECT * FROM foo"); # Now @$rows contains all the row data. # Use @$rows like $rows->[$row_number]->[$column_number]... foreach my $row (@$rows) { # ...or @$row like $row->[$column_number] } # Repeat as required, as long as $rows is still defined. # $sth->finish(); # Update per pope (Not required, no $sth defined)