I have used PAR in conjunction with perlcc to create a portable Perl executable
compiled with perlcc. Here is what I did:
In my Perl program (program.pl) I prepend $BASEDIR/lib to @INC with the
following code:
BEGIN {
require Cwd;
my($path)=($0 =~ m:^/: ? $0 : Cwd::getcwd()."/".$0);
$path=~s:/[^/]*$:/lib:;
# Replace /./ or // with /
while ($path =~ m</\.?/>) { $path=~s:/\.?/:/:; }
while ($path =~ m</\.\./>) {
# Replace .*/../ with nothing
$path=~s:[^/]*/\.\./::;
# Add leading / if missing
$path=~s:^([^/]):/$1:;
}
unshift @INC,$path;
}
In my Makefile for my program executable, I use pp to build a .zip file
containing all the required libraries needed in the lib directory. I then
extract the lib/ directory and discard the zip file, followed by perlcc to
compile my Perl script.
program: program.pl
pp -P -B -o program.zip program.pl
/bin/rm -rf lib
unzip program.zip 'lib/*'
/bin/rm program.zip
perlcc -o program program.pl
I am then able to take my executable and lib/ directory to another system and
run the program.
Would it be possible to add an option to pp that would allow you to create the
lib/ directory in the current working directory w/o having to resort to using
unzip?
Regards,
Seann Herdejurgen