pp - Perl Packager
pp [ -BILMSVXdeghilmoprsv ] [ parfile | scriptfile ]...
% pp hello # Pack 'hello' into executable 'a.out' % pp -o hello hello.pl # Pack 'hello.pl' into executable 'hello' % pp -o foo foo.pl bar.pl # Pack 'foo.pl' and 'bar.pl' into 'foo' % ./foo # Run 'foo.pl' inside 'foo' % mv foo bar; ./bar # Run 'bar.pl' inside 'foo' % mv bar baz; ./baz # Error: Can't open perl script "baz" % pp -p file # Creates a PAR file, 'file.par' % pp -o hello file.par # Pack 'file.par' to executable 'hello' % pp -S -o hello file # Combine the two steps above % pp -p -o out.par file # Creates 'out.par' from 'file' % pp -B -p -o out.par file # same as above, but bundles core modules % pp -P -o out.pl file # Creates 'out.pl' from 'file' % pp -B -p -o out.pl file # same as above, but bundles core modules # (-B is assumed when making executables) % pp -e 'print q//' # Pack a one-liner into 'a.out' % pp -p -e 'print q//' # Creates a PAR file 'a.out.par' % pp -I /foo hello # Extra paths (notice space after -I) % pp -M Foo::Bar hello # Extra modules (notice space after -M) % pp -M abbrev.pl hello # Extra files under @INC % pp -X Foo::Bar hello # Exclude modules (notice space after -X) % pp -r hello # Pack 'hello' into 'a.out', runs 'a.out' % pp -r hello a b c # Pack 'hello' into 'a.out', runs 'a.out' # with arguments 'a b c' % pp hello --log=c # Pack 'hello' into 'a.out', logs # messages into 'c' # Pack 'hello' into a console-less 'out.exe' with icon (Win32 only) % pp --gui --icon hello.ico -o out.exe hello
pp creates standalone executables from Perl programs, using the compressed packager provided by PAR, and dependency detection heuristics offered by Module::ScanDeps. Source files are compressed verbatim without compilation.
You may think of pp as "perlcc that works without hassle". :-)
A GUI interface is also available as the tkpp command.
It does not provide the compilation-step acceleration provided by perlcc (however, see -f below for byte-compiled, source-hiding techniques), but makes up for it with better reliability, smaller executable size, and full retrieval of original source code.
When a single input program is specified, the resulting executable will behave identically as that program. However, when multiple programs are packaged, the produced executable will run the one that has the same basename as $0 (i.e. the filename used to invoke it). If nothing matches, it dies with the error Can't open perl script "$0".
$0
Can't open perl script "$0"
On Microsoft Windows platforms, a.exe is used instead of a.out as the default executable name.
Options are available in a short form and a long form. For example, the three lines below are all equivalent:
% pp -o output.exe input.pl % pp --output output.exe input.pl % pp --output=output.exe input.pl
Adds the specified module into the package, along with its dependencies. Also accepts filenames relative to the @INC path; i.e. -M Module::ScanDeps means the same thing as -M Module/ScanDeps.pm.
@INC
-M Module::ScanDeps
-M Module/ScanDeps.pm
If FILE does not have a .pm/.ix/.al extension, it will not be scanned for dependencies, and will be placed under / instead of /lib/ inside the PAR file.
.pm
.ix
.al
/
/lib/
Bundles core modules in the resulting package. This option is enabled by default, except when -p or -P is specified.
-p
-P
Reduce the executable size by not including a copy of perl interpreter. Executables built this way will need a separate perl5x.dll or libperl.so to function correctly. This option is only available if perl is built as a shared library.
Package a one-liner, much the same as perl -e '...'
perl -e '...'
Excludes the given module from the dependency search patch and from the package.
Filter source script(s) with a PAR::Filter subclass. You may specify multiple such filters.
If you wish to hide the source code from casual prying, this will do:
% pp -f Bleach source.pl
Users with Perl 5.8.1 and above may also try out the experimental byte-compiling filter, which will strip away all comments and indents:
% pp -f Bytecode source.pl
Build an executable that does not have a console window. This option is ignored on non-MSWin32 platforms or when -p is specified.
Shows basic usage information.
Specify an icon file for the executable. This option is ignored on non-MSWin32 platforms or when -p is specified.
Add additional information for the packed file, both in META.yml and in the executable header (if applicable). The name/value pair is separated by =. You may specify -N multiple times.
META.yml
=
-N
For Win32 executables, these special KEY names are recognized:
KEY
Comments CompanyName FileDescription FileVersion InternalName LegalCopyright LegalTrademarks OriginalFilename ProductName ProductVersion
This feature is currently unimplemented.
Adds the given directory to the perl library file search path.
Adds the given shared library (a.k.a. shared object or DLL) into the packed file. Also accepts names under library paths; i.e. -l ncurses means the same thing as -l libncurses.so or -l /usr/local/lib/libncurses.so in most Unixes.
-l ncurses
-l libncurses.so
-l /usr/local/lib/libncurses.so
Log the output of packaging to a file rather than to stdout.
Filter included perl module(s) with a PAR::Filter subclass. You may specify multiple such filters.
Build a multi-architecture PAR file. Implies -p.
Specifies the file name for the final packaged executable.
Create PAR archives only; do not package to a standalone binary.
Create stand-alone perl script; do not package to a standalone binary.
Run the resulting packaged script after packaging it.
Do not delete generated PAR file after packaging.
Cryptographically sign the generated PAR or binary file using Module::Signature.
Increase verbosity of output; NUMBER is an integer from 0 to 5, 5 being the most verbose. Defaults to 1 if specified without an argument.
0
5
1
Display the version number and copyrights of this program.
Command-line options (switches). Switches in this variable are taken as if they were on every pp command line.
Here are some recipes showing how to utilize pp to bundle source.pl with all its dependencies, on target machines with different expected settings:
% pp -o packed.exe source.pl # makes packed.exe # Now, deploy 'packed.exe' to target machine... $ packed.exe # run it
% pp -B -P -o packed.pl source.pl # makes packed.exe # Now, deploy 'packed.exe' to target machine... $ perl packed.pl # run it
% pp -P -o packed.pl source.pl # makes packed.exe # Now, deploy 'packed.pl' to target machine... $ perl packed.pl # run it
% pp -p source.pl # makes source.par % echo "use PAR 'source.par';" > packed.pl; % cat source.pl >> packed.pl; # makes packed.pl # Now, deploy 'source.par' and 'packed.pl' to target machine... $ perl packed.pl # run it
Note that even if your perl was built with a shared library, the 'Stand-alone setup' above will not need a separate perl5x.dll or libperl.so to function correctly. Use --dependent if you are willing to ship the shared library with the application, which can significantly reduce the executable size.
--dependent
tkpp, par.pl, parl, perlcc
PAR, Module::ScanDeps
Simon Cozens, Tom Christiansen and Edward Peschko for writing perlcc; this program try to mimic its interface as close as possible, and copied liberally from their code.
Jan Dubois for writing the exetype.pl utility, which has been partially adapted into the -g flag.
-g
Mattia Barbon for providing the myldr binary loader code.
myldr
Jeff Goff for suggesting the name pp.
pp
Autrijus Tang <autrijus@autrijus.org>
http://par.perl.org/ is the official PAR website. You can write to the mailing list at <par@perl.org>, or send an empty mail to <par-subscribe@perl.org> to participate in the discussion.
Please submit bug reports to <bug-par@rt.cpan.org>.
Copyright 2002, 2003 by Autrijus Tang <autrijus@autrijus.org>.
Neither this program nor the associated parl program impose any licensing restrictions on files generated by their execution, in accordance with the 8th article of the Artistic License:
"Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package."
Therefore, you are absolutely free to place any license on the resulting executable, as long as the packed 3rd-party libraries are also available under the Artistic License.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
To install PAR, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PAR
CPAN shell
perl -MCPAN -e shell install PAR
For more information on module installation, please visit the detailed CPAN module installation guide.