One way is to use a cursor to fetch only up to a specified number of results from the join, before sending it to perl.
In a LOOP, FETCH each result and increment a counter (in SQL). If it's PL/SQL, use an EXIT WHEN statement that checks both the result of the fetch and the value of the counter.