fionbarr has asked for the wisdom of the Perl Monks concerning the following question:

I am using CAM::PDF to parse PDF files. I get an error in the routine 'parseAny' with the message 'unrecognized type in parseAny' and it DIES! rather than reporting an error and 'next'. Do anyone have experience/fix for this? Do I need to modify the module this sits in to solve the problem?

Replies are listed 'Best First'.
Re: parseAny in CAM::PDF
by Anonymous Monk on Nov 17, 2009 at 17:16 UTC
      I have hundreds of thousands of PDF files to pull apart...most of them work fine but when the program 'dies' I'm in big trouble...I can handle bypassing a file and reporting some problem but when the program exits it's no good. Any ideas?

        Maybe wrap an eval { } block around the respective call you're making to CAM::PDF?

Re: parseAny in CAM::PDF
by fionbarr (Friar) on Nov 17, 2009 at 18:42 UTC
    this was an excellent idea! I think it works. THANKS!
    # 11-17-2009....idea from perlmonks...trap a 'die'...it may work! eval {$doc = CAM::PDF->new($filename)}; if ($@) { print "skipping $filename because of parseAny\n"; print EXTRA "bad parseAny for $filename\n"; print SKIPPED_FILE_LIST "bad parseAny for $filename\n"; return 1; }