[Chicago-talk] Project note: PAR, executables, etc.

Greg Fast gdf at speakeasy.net
Fri May 7 16:22:06 CDT 2004

I mentioned this project back in March, and just had the chance to get
back to it.  I figured I'd write a update, since I learned a little
about PAR.

The project is a perl program with a payload.  Specifically, with an
archive containing some java class files and a JVM to run them.  The
program basically finds the payload, then does a
system("java","com.example.Proggie").  This gets around the need to
install a JVM before running the (Java) app.  (Let's assume for the
purposes of the exercise that this is reasonable.)  Finally, the perl
program is turned into a self-contained executable which can be handed
to clicky types.

Because I have access to PerlApp and I've used it before, I assumed
I'd use that to create the EXE.  Several people suggested I look at

It took me a while to realize that PAR's "pp" utility has the ability
to create executables *without* requiring a native compiler (the docs
have improved a lot since I first looked at it). I'd been assuming it
was using some sort of wacky perlcc hackery.  It actually works by
pre-compiling an executable header during the "make" phase of
installation, which "pp" just glues to the top of a chunk of PAR
archive data and the perl interpreter.  So once PAR is installed,
everything is pure perl.  This is a neat trick.

However, PAR is aimed at collections of perl modules, more than at
self-contained applications.  You can add non-module resources to the
PAR/executable, but they lose directory structure information
("foo/bar.txt" gets stored as "/bar.txt").  Furthermore, since PAR is
all tricky internally, it's complicated to access non-module files for
doing things like copying files from the archive, or executing archive
entries as programs ("java.exe", in my case).

So I wrote Archive::SelfExtract, which handles the payload bit.  (It
hasn't been exercised much in the wild yet, so it's probably got
another couple of bugfix iterations to go.)  Now I can write my
bootstrap script, then do:

  bash$ mkselfextract bootstrap.pl javanstuff.zip > temp.pl
  bash$ pp -o install temp.pl

Greg Fast

More information about the Chicago-talk mailing list