my @items_to_include = qw/1 11 45 73 27/; my $query = "SELECT * FROM catalog WHERE "; $query .= join " OR ", ("item_id=?") x @items_to_include; my $sth = $dbh->prepare($query); $sth->execute(@items_to_include);