Some of the PDF files, it works fine. For many PDF files it throws an error as:

Premature end of file reached at valid.pl line 5
Bad object reference '' at valid.pl line 5
Bad object reference '' at valid.pl line 5
Bad object reference '' at valid.pl line 5
Use of uninitialized value in concatenation (.) or string at valid.pl +line 9.
Use of uninitialized value in concatenation (.) or string at valid.pl +line 9.
1.6