$stmt = qq/SELECT * FROM table WHERE id IN (/ . join(',', ('?') x $categories ) . qq/)/; $sth = $dbh->prepare($stmt); $sth->execute($categories);