Perl Binaries with PAR
This is something that rears it’s ugly head from time to time, the need to create stand alone scripts that I can give to a none programmer to run on a Windows box. The last time I played with this, it was to create a version of the get_iplayer script for my dad to run. This time it was to run some network diagnostics scripts we’d hacked together on a machine we had no access to.
The machine we needed to run it on was a fairly well locked down ‘doze box, so installing Perl was unlikely to happen. The last time I used a nice little app called linux2perl. It worked fairly well, but the free version had a 2 second delay and a splash message on the start of the app.
So I decided to take a look at the Perl Archiving Toolkit (PAR). The PAR toolkit actually generates intermediate shippable packages, that are actually zip files with all the required modules included to run a script. So a PAR script can be packaged up and shipped to any user with perl and it’ll run regardless of architecture (almost… think XS), or installed modules.
To my delight, creating an executable was nice and simple:
pp -o outfile.exe infile.pl
PP is the PAR Packager, which is nice little utility to convert the PAR files to executables for the current OS. Or as the CPAN page puts it “You may think of pp as perlcc that works without hassle.”
You’ll still need a windows box to build the binaries, but once they’re built they are completely shippable and can be sent to other boxes. Although they do end up being rather large, my simple script was a little under 4 Meg, leading me to wonder if more than just the libraries I used were packaged up too.
Either way it worked perfectly, I even repackaged the get_iplayer script for the old man.
0 comments
Kick things off by filling out the form below.
Leave a Comment