.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PAR 3pm" .TH PAR 3pm "2011-12-02" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PAR \- Perl Archive Toolkit .SH "SYNOPSIS" .IX Header "SYNOPSIS" (If you want to make an executable that contains all module, scripts and data files, please consult the pp utility instead. pp used to be part of the \s-1PAR\s0 distribution but is now shipped as part of the PAR::Packer distribution instead.) .PP Following examples assume a \fIfoo.par\fR file in Zip format. .PP To use \fIHello.pm\fR from \fI./foo.par\fR: .PP .Vb 2 \& % perl \-MPAR=./foo.par \-MHello \& % perl \-MPAR=./foo \-MHello # the .par part is optional .Ve .PP Same thing, but search \fIfoo.par\fR in the \f(CW@INC\fR; .PP .Vb 2 \& % perl \-MPAR \-Ifoo.par \-MHello \& % perl \-MPAR \-Ifoo \-MHello # ditto .Ve .PP Following paths inside the \s-1PAR\s0 file are searched: .PP .Vb 6 \& /lib/ \& /arch/ \& /i386\-freebsd/ # i.e. $Config{archname} \& /5.8.0/ # i.e. $Config{version} \& /5.8.0/i386\-freebsd/ # both of the above \& / .Ve .PP \&\s-1PAR\s0 files may also (recursively) contain other \s-1PAR\s0 files. All files under following paths will be considered as \s-1PAR\s0 files and searched as well: .PP .Vb 4 \& /par/i386\-freebsd/ # i.e. $Config{archname} \& /par/5.8.0/ # i.e. $Config{version} \& /par/5.8.0/i386\-freebsd/ # both of the above \& /par/ .Ve .PP Run \fIscript/test.pl\fR or \fItest.pl\fR from \fIfoo.par\fR: .PP .Vb 1 \& % perl \-MPAR foo.par test.pl # only when $0 ends in \*(Aq.par\*(Aq .Ve .PP However, if the \fI.par\fR archive contains either \fIscript/main.pl\fR or \&\fImain.pl\fR, then it is used instead: .PP .Vb 1 \& % perl \-MPAR foo.par test.pl # runs main.pl; @ARGV is \*(Aqtest.pl\*(Aq .Ve .PP Use in a program: .PP .Vb 2 \& use PAR \*(Aqfoo.par\*(Aq; \& use Hello; # reads within foo.par \& \& # PAR::read_file() returns a file inside any loaded PARs \& my $conf = PAR::read_file(\*(Aqdata/MyConfig.yaml\*(Aq); \& \& # PAR::par_handle() returns an Archive::Zip handle \& my $zip = PAR::par_handle(\*(Aqfoo.par\*(Aq) \& my $src = $zip\->memberNamed(\*(Aqlib/Hello.pm\*(Aq)\->contents; .Ve .PP You can also use wildcard characters: .PP .Vb 1 \& use PAR \*(Aq/home/foo/*.par\*(Aq; # loads all PAR files in that directory .Ve .PP Since version 0.950, you can also use a different syntax for loading \&\fI.par\fR archives: .PP .Vb 1 \& use PAR { file => \*(Aqfoo.par\*(Aq }, { file => \*(Aqotherfile.par\*(Aq }; .Ve .PP Why? Because you can also do this: .PP .Vb 2 \& use PAR { file => \*(Aqfoo.par, fallback => 1 }; \& use Foo::Bar; .Ve .PP Foo::Bar will be searched in the system libs first and loaded from \fIfoo.par\fR if it wasn't found! .PP .Vb 1 \& use PAR { file => \*(Aqfoo.par\*(Aq, run => \*(Aqmyscript\*(Aq }; .Ve .PP This will load \fIfoo.par\fR as usual and then execute the \fIscript/myscript\fR file from the archive. Note that your program will not regain control. When \&\fIscript/myscript\fR exits, so does your main program. To make this more useful, you can defer this to runtime: (otherwise equivalent) .PP .Vb 2 \& require PAR; \& PAR\->import( { file => \*(Aqfoo.par\*(Aq, run => \*(Aqmyscript\*(Aq } ); .Ve .PP If you have PAR::Repository::Client installed, you can do this: .PP .Vb 2 \& use PAR { repository => \*(Aqhttp://foo/bar/\*(Aq }; \& use Module; # not locally installed! .Ve .PP And \s-1PAR\s0 will fetch any modules you don't have from the specified \s-1PAR\s0 repository. For details on how this works, have a look at the \s-1SEE\s0 \s-1ALSO\s0 section below. Instead of an \s-1URL\s0 or local path, you can construct an PAR::Repository::Client object manually and pass that to \s-1PAR\s0. If you specify the \f(CW\*(C`install => 1\*(C'\fR option in the \f(CW\*(C`use PAR\*(C'\fR line above, the distribution containing \f(CW\*(C`Module\*(C'\fR will be permanently installed on your system. (\f(CW\*(C`use PAR { repository => \*(Aqhttp://foo/bar\*(Aq, install => 1 };\*(C'\fR) .PP Furthermore, there is an \f(CW\*(C`upgrade => 1\*(C'\fR option that checks for upgrades in the repository in addition to installing. Please note that an upgraded version of a module is only loaded on the next run of your application. .PP Adding the \f(CW\*(C`dependencies => 1\*(C'\fR option will enable PAR::Repository::Client's static dependency resolution (PAR::Repository::Client 0.23 and up). .PP Finally, you can combine the \f(CW\*(C`run\*(C'\fR and \f(CW\*(C`repository\*(C'\fR options to run an application directly from a repository! (And you can add the \f(CW\*(C`install\*(C'\fR option, too.) .PP .Vb 2 \& use PAR { repository => \*(Aqhttp://foo/bar/\*(Aq, run => \*(Aqmy_app\*(Aq }; \& # Will not reach this point as we executed my_app, .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module lets you use special zip files, called \fBP\fRerl \fBAr\fRchives, as libraries from which Perl modules can be loaded. .PP It supports loading \s-1XS\s0 modules by overriding \fBDynaLoader\fR bootstrapping methods; it writes shared object file to a temporary file at the time it is needed. .PP A \fI.par\fR file is mostly a zip of the \fIblib/\fR directory after the build process of a \s-1CPAN\s0 distribution. To generate a \fI.par\fR file yourself, all you have to do is compress the modules under \fIarch/\fR and \fIlib/\fR, e.g.: .PP .Vb 4 \& % perl Makefile.PL \& % make \& % cd blib \& % zip \-r mymodule.par arch/ lib/ .Ve .PP Afterward, you can just use \fImymodule.par\fR anywhere in your \f(CW@INC\fR, use \fB\s-1PAR\s0\fR, and it will Just Work. Support for generating \fI.par\fR files is going to be in the next (beyond 0.2805) release of Module::Build. .PP For convenience, you can set the \f(CW\*(C`PERL5OPT\*(C'\fR environment variable to \&\f(CW\*(C`\-MPAR\*(C'\fR to enable \f(CW\*(C`PAR\*(C'\fR processing globally (the overhead is small if not used); setting it to \f(CW\*(C`\-MPAR=/path/to/mylib.par\*(C'\fR will load a specific \s-1PAR\s0 file. Alternatively, consider using the \fIpar.pl\fR utility bundled with the PAR::Packer distribution, or using the self-contained \fIparl\fR utility which is also distributed with PAR::Packer on machines without \s-1PAR\s0.pm installed. .PP Note that self-containing scripts and executables created with \fIpar.pl\fR and \fIpp\fR may also be used as \fI.par\fR archives: .PP .Vb 3 \& % pp \-o packed.exe source.pl # generate packed.exe (see PAR::Packer) \& % perl \-MPAR=packed.exe other.pl # this also works \& % perl \-MPAR \-Ipacked.exe other.pl # ditto .Ve .PP Please see \*(L"\s-1SYNOPSIS\s0\*(R" for most typical use cases. .SH "NOTES" .IX Header "NOTES" Settings in \fI\s-1META\s0.yml\fR packed inside the \s-1PAR\s0 file may affect \s-1PAR\s0's operation. For example, \fIpp\fR provides the \f(CW\*(C`\-C\*(C'\fR (\f(CW\*(C`\-\-clean\*(C'\fR) option to control the default behavior of temporary file creation. .PP Currently, \fIpp\fR\-generated \s-1PAR\s0 files may attach four PAR-specific attributes in \fI\s-1META\s0.yml\fR: .PP .Vb 5 \& par: \& clean: 0 # default value of PAR_CLEAN \& signature: \*(Aq\*(Aq # key ID of the SIGNATURE file \& verbatim: 0 # was packed prerequisite\*(Aqs PODs preserved? \& version: x.xx # PAR.pm version that generated this PAR .Ve .PP User-defined environment variables, like \fI\s-1PAR_GLOBAL_CLEAN\s0\fR, always overrides the ones set in \fI\s-1META\s0.yml\fR. The algorithm for generating caching/temporary directory is as follows: .IP "\(bu" 4 If \fI\s-1PAR_GLOBAL_TEMP\s0\fR is specified, use it as the cache directory for extracted libraries, and do not clean it up after execution. .IP "\(bu" 4 If \fI\s-1PAR_GLOBAL_TEMP\s0\fR is not set, but \fI\s-1PAR_CLEAN\s0\fR is specified, set \&\fI\s-1PAR_GLOBAL_TEMP\s0\fR to \f(CW\*(C`\f(CITEMP\f(CW/par\-\f(CIUSER\f(CW/temp\-\f(CIPID\f(CW/\*(C'\fR, cleaning it after execution. .IP "\(bu" 4 If both are not set, use \f(CW\*(C`\f(CITEMP\f(CW/par\-\f(CIUSER\f(CW/cache\-\f(CIHASH\f(CW/\*(C'\fR as the \&\fI\s-1PAR_GLOBAL_TEMP\s0\fR, reusing any existing files inside. .PP Here is a description of the variables the previous paths. .IP "\(bu" 4 \&\fI\s-1TEMP\s0\fR is a temporary directory, which can be set via \&\f(CW$ENV{PAR_GLOBAL_TMPDIR}\fR, \&\f(CW$ENV{TMPDIR}\fR, \f(CW$ENV{TEMPDIR}\fR, \f(CW$ENV{TEMP}\fR or \f(CW$ENV{TMP}\fR, in that order of priority. If none of those are set, \fIC:\eTEMP\fR, \fI/tmp\fR are checked. If neither of them exists, \fI.\fR is used. .IP "\(bu" 4 \&\fI\s-1USER\s0\fR is the user name, or \s-1SYSTEM\s0 if none can be found. On Win32, this is \f(CW$Win32::LoginName\fR. On Unix, this is \f(CW$ENV{USERNAME}\fR or \&\f(CW$ENV{USER}\fR. .IP "\(bu" 4 \&\fI\s-1PID\s0\fR is the process \s-1ID\s0. Forked children use the parent's \s-1PID\s0. .IP "\(bu" 4 \&\fI\s-1HASH\s0\fR is a crypto-hash of the entire par file or executable, calculated at creation time. This value can be overloaded with \f(CW\*(C`pp\*(C'\fR's \&\-\-tempdir parameter. .PP By default, \s-1PAR\s0 strips \s-1POD\s0 sections from bundled modules. In case that causes trouble, you can turn this off by setting the environment variable \f(CW\*(C`PAR_VERBATIM\*(C'\fR to \f(CW1\fR. .SS "import options" .IX Subsection "import options" When you \*(L"use \s-1PAR\s0 {...}\*(R" or call \s-1PAR\-\s0>import({...}), the following options are available. .PP .Vb 3 \& PAR\->import({ file => \*(Aqfoo.par\*(Aq }); \& # or \& PAR\->import({ repository => \*(Aqhttp://foo/bar/\*(Aq }); .Ve .IP "file" 4 .IX Item "file" The par filename. .Sp You must pass \fIone\fR option of either 'file' or 'repository'. .IP "repository" 4 .IX Item "repository" A par repository (exclusive of file) .IP "fallback" 4 .IX Item "fallback" Search the system \f(CW@INC\fR before the par. .Sp Off by default for loading \fI.par\fR files via \f(CW\*(C`file =\*(C'\fR ...>. On by default for \s-1PAR\s0 repositories. .Sp To prefer loading modules from a repository over the locally installed modules, you can load the repository as follows: .Sp .Vb 1 \& use PAR { repository => \*(Aqhttp://foo/bar/\*(Aq, fallback => 0 }; .Ve .IP "run" 4 .IX Item "run" The name of a script to run in the par. Exits when done. .IP "no_shlib_unpack" 4 .IX Item "no_shlib_unpack" Skip unpacking bundled dynamic libraries from shlib/$archname. The client may have them installed, or you may wish to cache them yourself. In either case, they must end up in the standard install location (such as /usr/local/lib/) or in \f(CW$ENV\fR{\s-1PAR_TEMP\s0} \fIbefore\fR you require the module which needs them. If they are not accessible before you require the dependent module, perl will die with a message such as \*(L"cannot open shared object file...\*(R" .SH "SEE ALSO" .IX Header "SEE ALSO" The \s-1PAR\s0 homepage at . .PP PAR::Tutorial, \s-1PAR::FAQ\s0 (For a more current \s-1FAQ\s0, refer to the homepage.) .PP The PAR::Packer distribution which contains the packaging utilities: par.pl, parl, pp. .PP PAR::Dist for details on \s-1PAR\s0 distributions. .PP PAR::Repository::Client for details on accessing \s-1PAR\s0 repositories. PAR::Repository for details on how to set up such a repository. .PP Archive::Zip, \*(L"require\*(R" in perlfunc .PP ex::lib::zip, Acme::use::strict::with::pride .PP Steffen Mueller has detailed slides on using \s-1PAR\s0 for application deployment at http://steffen\-mueller.net/talks/appdeployment/ . .PP \&\s-1PAR\s0 supports the prefork module. It declares various run-time dependencies so you can use the prefork module to get streamlined processes in a forking environment. .SH "ACKNOWLEDGMENTS" .IX Header "ACKNOWLEDGMENTS" Nicholas Clark for pointing out the mad source filter hook within the (also mad) coderef \f(CW@INC\fR hook, as well as (even madder) tricks one can play with PerlIO to avoid source filtering. .PP Ton Hospel for convincing me to ditch the \f(CW\*(C`Filter::Simple\*(C'\fR implementation. .PP Uri Guttman for suggesting \f(CW\*(C`read_file\*(C'\fR and \f(CW\*(C`par_handle\*(C'\fR interfaces. .PP Antti Lankila for making me implement the self-contained executable options via \f(CW\*(C`par.pl \-O\*(C'\fR. .PP See the \fI\s-1AUTHORS\s0\fR file in the distribution for a list of people who have sent helpful patches, ideas or comments. .SH "AUTHORS" .IX Header "AUTHORS" Audrey Tang .PP Steffen Mueller .PP is the official \s-1PAR\s0 website. You can write to the mailing list at , or send an empty mail to to participate in the discussion. .PP Please submit bug reports to . If you need support, however, joining the mailing list is preferred. .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2002\-2010 by Audrey Tang . Copyright 2005\-2010 by Steffen Mueller .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP See