my $qm = join ',', ('?') x @allsearchterms; my $sth = $dbh->prepare("select * from table where value in($qm)"); $sth->execute(@allsearchterms);