my $count_sth = $dbh->prepare( 'SELECT count(*) FROM subscription WHERE userid IN (' . join(',', "?" x @compare_array) . ')'); $count_sth->execute(@compare_array); my $count = $count_sth->fetchrow_array;