Subject: | infinite memory consumption? |
Hi,
may be it is my fault, while I'm pretty unexperienced n Perl, but I can't find any "close"-like method for CAM-PDF.
Using attached script the memory consumption goes to infinite after reading (or just opening without reading) several hundreds of files.
It seems to me, that memory is never deallocated after once onening a file by _new CAM::PDF("$file")_ ?
using:
- Perl 5.8.6 on Win32 (Activestate or Indigostar distribution)
- CAM-PDF 0.99
- Win2k
Thanks in advance.
Berry
#!/bin/perl -w
use strict;
use Cwd;
use CAM::PDF;
my $filetype = "*.pdf";
my $dir = "d:/perlscripts/md5/test";
chdir("$dir");
my @files=getfiles();
foreach my $file (sort @files) {
my $isbn_string = "";
my $isbn = &getISBNfromPDF("$dir\/$file");
if ($isbn) {
print "$file: $isbn\n";
}
else {
print "$file: :(\n";
}
}
sub getfiles {
return glob("$filetype");
} # endsub
sub getISBNfromPDF {
my $file = $_[0];
my $pdf;
my $match;
if ($pdf = new CAM::PDF("$file")) {
my $nbrPages = $pdf->numPages();
for (my $nbr=1;$nbr<=$nbrPages;$nbr++) {
my $page = $pdf->getPageText($nbr);
if (($page) && ($page =~ /(I\s?S\s?B\s?N\:?\s?[0-9X\.\-\s]+)/i)) {
$match = $1;
last;
}
}
}
return $match;
} # endsub