1) $pdf is an PDF::API2-object that is created outside the subroutine as a package-global.
2) I donīt consider globals to be bad in short scripts. I am using strict, but i did post only the relevant subroutine.
3) The same thing. The error does not relate to the number of documents.
4) I will update my code-section.
Ok ... This sounds like a bug in PDF::API2. I would build a test case with 4 very simple PDF files and open a bug at http://rt.cpan.org. It's a very interesting bug, I'll say that ...
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.