$dbh = DBI->connect('..', '..', '..'); $sth = $dbh->prepare(q{select ..}); if ($sth && !$sth->errstr()) { while (my $row = $sth->fetchrow_arrayref()) { .. } }