(my $buddy_count = $dbh->selectrow_array ("SELECT COUNT(*) FROM profile") ) or die "query failed" #### Also, in a scalar context, an undef is returned if there are no more rows or if an error occurred. That undef can't be distinguished from an undef returned because the first field value was NULL. For these reasons you should exercise some caution if you use selectrow_array in a scalar context, or just don't do that.