my $sth = $dbh->prepare("SELECT * FROM foo"); $sth->execute(); while (my $row = $sth->fetchrow_arrayref()) { # Use @$row like $row->[0], $row->[1], etc. } $sth->finish(); # Important!