my @results; while (my @row = $sth->fetchrow_array) { push @results,\@row; } if (@results) { ...we got something... } else { ...we got nothing... } #### my $results = 0; while (my @row = $sth->fetchrow_array) { $results++; ...do some stuff } if ($results) { ...we got something... } else { ...we got nothing... }