... my $count = $sth->execute or die; my $total = 0; while (my $rows = $sth->fetchall_arrayref([0], 3)) { die "Error: $DBI::errstr" if $DBI::err; # error different # to 'end of while' for (@$rows) { print "got @$_\n"; } print "---\n"; $total += scalar @$rows; last if $total == $count; }