The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

PAR - Perl Archive Toolkit

VERSION

This document describes version 0.48 of PAR, released November 13, 2002.

SYNOPSIS

(If you want to make an executable that contains all module, scripts and data files, please consult pp instead.)

Following examples assume a foo.par file in Zip format; support for compressed gzip (*.tgz) format is under consideration.

To use Hello.pm from ./foo.par:

    % perl -MPAR=./foo.par -MHello
    % perl -MPAR=./foo -MHello          # the .par part is optional

Same thing, but search foo.par in the @INC;

    % perl -MPAR -Ifoo.par -MHello
    % perl -MPAR -Ifoo -MHello          # ditto

The search path for the above two examples are:

    /
    /lib/
    /arch/
    /i386-freebsd/              # i.e. $Config{archname}
    /5.8.0/                     # i.e. Perl version number
    /5.8.0/i386-freebsd/        # both of the above

Run test.pl or script/test.pl from foo.par:

    % perl -MPAR foo.par test.pl        # only when $0 ends in '.par'

However, if the .par archive contains either main.pl or script/main.pl, then it is used instead:

    % perl -MPAR foo.par test.pl        # runs main.pl, with 'test.pl' as @ARGV

Use in a program:

    use PAR 'foo.par';
    use Hello; # reads within foo.par

    # PAR::read_file() returns a file inside any loaded PARs
    my $conf = PAR::read_file('data/MyConfig.yaml');

    # PAR::par_handle() returns an Archive::Zip handle
    my $zip = PAR::par_handle('foo.par')
    my $src = $zip->memberNamed('lib/Hello.pm')->contents;

DESCRIPTION

This module lets you easily bundle a typical blib/ tree into a zip file, called a Perl Archive, or PAR.

To generate a .par file, all you have to do is compress the modules under arch/ and lib/, e.g.:

    % perl Makefile.PL
    % make
    % cd blib
    % zip -r mymodule.par arch/ lib/

Afterwards, you can just use mymodule.par anywhere in your @INC, use PAR, and it will Just Work.

For maximal convenience, you can set the PERL5OPT environment variable to -MPAR to enable PAR processing globally (the overhead is small if not used), or to -MPAR=/path/to/mylib.par to load a specific PAR file. Alternatively, consider using the par.pl utility bundled with this module.

Note that self-containing scripts and executables created with par.pl and pp may also be used as .par archives:

    % pp -O packed.exe source.pl        # generate packed.exe
    % perl -MPAR=packed.exe other.pl    # this can also work
    % perl -MPAR -Ipacked.exe other.pl  # ditto

Please see "SYNOPSIS" for most typical use cases.

NOTES

Since version 0.10, this module supports loading XS modules by overriding DynaLoader boostrapping methods; it writes shared object file to a temporary file at the time it is needed, and removes it when the program terminates. Currently there are no plans to leave them around for the next time, but if you need the functionality, just mail me. ;-)

SEE ALSO

My presentation, "Introduction to Perl Archive Toolkit": http://www.autrijus.org/par-intro/slide001.html

par.pl, pp

Archive::Zip, "require" in perlfunc

ex::lib::zip, Acme::use::strict::with::pride

ACKNOWLEDGMENTS

Nicholas Clark for pointing out the mad source filter hook within the (also mad) coderef @INC hook, as well as (even madder) tricks one can play with PerlIO to avoid source filtering.

Ton Hospel for convincing me to ditch the Filter::Simple implementation.

Uri Guttman for suggesting read_file and par_handle interfaces.

Antti Lankila for making me implement the self-contained executable options via par.pl -O.

See the AUTHORS file in the distribution for a list of people who have sent helpful patches, ideas or comments.

AUTHORS

Autrijus Tang <autrijus@autrijus.org>

COPYRIGHT

Copyright 2002 by Autrijus Tang <autrijus@autrijus.org>.

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