my $sql = join(",", @allsearchterms); my $sth = $dbh->prepare("select * from table where value in($sql)"); # You need to place qutes arount the sql-items, but you'll get the point here... $sth->execute();