my $results_ref = $dbh->selectall_arrayref(....); if (@$results_ref) { # ... do stuff } # or just get $count, (using `scalar` for clarity but it's already in scalar # context so works without it here) my $count = scalar @$results_ref;