http://www.perlmonks.org?node_id=1103645


in reply to [SOLVED] Problem merging thousands of PDFs with PDF::API2: 'Deep recursion on subroutine "PDF::API2::Basic::PDF::Objind::release"'

You're re-opening $out_pdf for every new input file, that may be one of the reasons. Try to open output pdf file just once before the while loop.