$where_clause = 'where id in ('.join(",",("?") x @id).')'; $sql .= $where_clause; my $sth = $dbh->prepare($sql); $sth->execute(@id);