my $all = $dbh->selectall_arrayref(" SELECT ID, col1, col2 FROM table WHERE col1 = 'xxx' "); print "Number of rows selected: ", 0+@$all, "\n";