I installed Imager::QRCode and PAR::Packer using cpan then used pp test.pl -o test.exe -c -x to generate a 7.8MB test.exe. I got the same results that you did. I then reworked your code to give better diagnostics and to be a little more modern (using lexical file handles):
use strict;
use warnings;
use diagnostics;
use Imager;
use Imager::QRCode;
use Imager::File::JPEG;
my $qrcode = Imager::QRCode->new (
size => 2,
margin => 2,
version => 1,
level => 'M',
casesensitive => 1,
lightcolor => Imager::Color->new(255, 255, 255),
darkcolor => Imager::Color->new(0, 0, 0),
);
my $img = $qrcode->plot('PDJ Test 1');
my @type = ('jpeg', 'png', 'gif', 'tiff', 'bmp', 'pnm', 'raw', 'sgi',
+'tga');
for (@type) {
my $fileName = "image.$_";
open my $image, '>', $fileName or die $!;
binmode $image or die $!;
my $imageOut = $img->write(fh => $image, type => $_) or die "Creat
+ing $fileName: $!";
print $image $imageOut;
}
When packed and the executable is run I get errors like:
Uncaught exception from user code:
Creating image.png: No such file or directory at script/delme.
+pl line 28.
As you can see from the sample code above explicitly including the appropriate image file modules fixes the problem (.jpg was a problematic format on my system). You could of course use -M Imager::File::JPEG ... on the pp command line to achieve the same result.
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
|