If you are attempting to satisfy dependencies for perl software that was NOT available via your favourite repository (this is sometimes unavoidable in enterprise environments) you should AT LEAST attempt to satisfy those dependencies using said repository. The easiest solution is to install ‘apt-file’ from your repo and for any perl modules you can simply call:
apt-file search "LWP::UserAgent"
This will return the following list on Debian Lenny:
liblwp-useragent-determined-perl: /usr/share/man/man3/LWP::UserAgent::Determined.3pm.gz
libtest-mock-lwp-perl: /usr/share/man/man3/Test::Mock::LWP::UserAgent.3pm.gz
libwww-perl: /usr/share/man/man3/LWP::UserAgent.3pm.gz
Now you know that in order to satisfy a dependency on “LWP::UserAgent” you would need to install the ‘libwww-perl’ module from the repo.
If the module is not available via the repo you should next consider installing the package into a custom perl lib directory specifically for the software (and/or user account) in question. To do this read the documentation for the local::lib module in CPAN.
Ultimately your goal should be to not install non-packaged software to /usr/local and by doing so increase the maintainability of your systems.
Posted in Linux, Programming | Comments (0)
I’m not sure this affects the newest version of MIME::Lite; however, if you find that you are having issues with your messages being rejected or marked as spam, due to an internal host being added to the Return-Path, the following fix might work for you.
Rather than using:
my $ml = MIME::Lite-new(
From => ...
To => ...
...
);
$ml->send();
Use the following:
$ml->send_by_sendmail(SetSender => 1);
Posted in Programming | Comments (1)
The perl module you’ll want to install is called PerlMagick (Image::Magick) and rather than loading the image into memory you can just use the Ping method. The Ping method returns an array with 4 elements of information for each page of a multi-page TIFF/PDF. If we divide the number of elements by 4 we know how many pages there are in the TIFF/PDF.
use Image::Magick;
my $im = Image::Magick->new();
my @ping_info = $im->Ping('fax.tif');
## If we access an @rray in a scalar context we get the element count
my $count = @ping_info / 4;
print $count;
There you have it, good luck.
UPDATE:
The example above may or may not work properly with PDF’s. Even if it does work it appears that ImageMagick makes an external call to the ghostscript (gs) executable on the system to determine the properties of the pdf. Here is an example that will work for PDFs:
use PDF::API2;
my $pdf = PDF::API2->open('2.pdf');
print $pdf->pages();
I’m guessing that eventually ImageMagick won’t be “broken” but you can use the above in the meantime.
Posted in Programming | Comments (1)