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

Hi All, I am using CAM::PDF module for reading pdf content. here is script which i m using. when executing my script i m getting error something "Can't use an undefined value as an ARRAY reference at C:/Perl/site/lib/CAM/PDF/PageText.pm line 57". Any help would be appreciated.
use CAM::PDF; use CAM::PDF::PageText; my $pdf = CAM::PDF->new(test.pdf); foreach (1..($pdf->numPages())) { my $page_cont = $pdf->getPageContentTree($_); print CAM::PDF::PageText->render($page_cont); }

Replies are listed 'Best First'.
Re: Using CAM::PDF module to read the pdf content
by Corion (Patriarch) on Mar 08, 2010 at 08:34 UTC

    You should use strict;. That way, Perl would tell you that you are missing quotes in your construction call to CAM::PDF->new:

    # my $pdf = CAM::PDF->new(test.pdf); # should be my $pdf = CAM::PDF->new("test.pdf");

    But you never check whether your call to CAM::PDF->new is successful, so you should do that as well:

    my $pdf = CAM::PDF->new("test.pdf") or die "Couldn't read PDF 'test.pdf'";
    A reply falls below the community's threshold of quality. You may see it by logging in.