develooper Front page | perl.par | Postings from August 2006

Shrinking PAR files (was Re: PAR::Filter::Squish)

Thread Previous | Thread Next
Chris Dolan
August 15, 2006 14:47
Shrinking PAR files (was Re: PAR::Filter::Squish)
Message ID:
On Aug 15, 2006, at 3:05 PM, Steffen Mueller wrote:

> Hi list,
> just a short notice: There is a new PAR filter on CPAN.  
> PAR::Filter::Squish uses Adam Kennedy's Perl::Squish to reduce the  
> size of the included source code. (Perl::Squish in turn uses PPI to  
> parse the Perl code.)
> Of course, the net benefit isn't usually too great since much of a  
> pp-ed executable consists of dlls. Your mileage may vary.
> Steffen
> P.S.:

On a vaguely-related topic, I've worked on shrinking my PAR-generated  
executables by more mundane means: excluding unneeded modules.  I've  
found a few tricks that can help a lot:

  * If you know the target platform has Perl pre-installed (e.g. Mac  
OS X) then use the "--dependent" flag

This skips all of the core modules, yielding a much smaller executable.

One significant caveat is moving to older systems.  For example, Mac  
OS X 10.2 had Perl 5.6.0 which has 146 fewer core modules than Perl  
5.8.6 which shipped with Mac OS X 10.4, and (even more significantly)  
is binary-incompatible with any extra XS modules added from CPAN.   
Other platforms can be even harder to predict.

  * Watch for modules that pull in lots of dependencies

A good example is DBI.  If your program uses DBI, then  
Module::ScanDeps pulls in ALL of the DBD::* modules (some of which  
are large) installed on your system, because it cannot realistically  
parse the DBI->connect() arguments which specify which database  
drivers are actually needed.  In one of my MySQL-based applications,  
I use this invocation of PAR:
   pp -X DBD::SQLite -X DBD::CSV -X DBD::File -X DBD::Excel
which saves quite a few bytes, because both DBD::SQLite and  
DBD::Excel have lots of CPAN dependencies.  The actual list if DBD::*  
modules you need to exclude depends on your system.  Here's a short  
command that will reveal all DBD::* modules on a unix-like system:
   perl -MModule::ScanDeps -le'print for map {"DBD/".$_->{name}}  

Another smaller example is SOAP::Transport::* where most  
installations only need SOAP::Transport::HTTP.


Chris Dolan, Software Developer, Clotho Advanced Media Inc.
608-294-7900, fax 294-7025, 1435 E Main St, Madison WI 53703

Clotho Advanced Media, Inc. - Creators of MediaLandscape Software  
( and partners in the revolutionary  
Croquet project (

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About