$stmt = qq/SELECT somedata FROM table WHERE id IN (/ . join(',', ('?') x @ids_to_match ) . qq/)/; $sth = $dbh->prepare($stmt); $sth->execute(@ids_to_match); my $results = $sth->fetchall_arrayref({});