Hello,

I've started learning 'pp' ( http://search.cpan.org/~smueller/PAR-Packer/lib/pp.pm ).

I think I understand how it works in general, and in practice I can create a stand-alone executable from a simple script.

So far so good.

I know that in reality I'll need to create stand-alone executable from a number of Perl scripts, so let's simplify this yo just father.pl calling son.pl .

Normally I would call son.pl (there are no command line arguments to it for simplicity):

system("$^X -w son.pl"); # it is assumed son.pl is in CWD
.

So, with 'pp' I have a problem WRT $^X.

This is my father script:

#!/home/sergei/PERL-5.10.0/bin/perl -w use strict; warn "this is father, \$0=$0 \$^X=$^X"; warn "father.pl: \@INC=\n", join("\n", @INC); warn "cwd: ", `pwd`; warn "PATH: ", `echo \$PATH`; my @PATH = split(':', $ENV{PATH}); warn "\$PATH[0]=$PATH[0]"; warn "father.pl: \$^X=$^X"; { warn "father.pl: about to check Perl (\$^X)"; my $cmd = "$^X -h"; warn "\$cmd=$cmd"; system($cmd); warn "father.pl: \$?=$?"; }
. When run from command line directly it works as expected:
" ./father.pl this is father, $0=./father.pl $^X=/home/sergei/PERL-5.10.0/bin/perl a +t ./father.pl line 7. father.pl: @INC= /home/sergei/PERL-5.10.0/lib/perl5/5.10.0/i686-linux-thread-multi /home/sergei/PERL-5.10.0/lib/perl5/5.10.0 /home/sergei/PERL-5.10.0/lib/perl5/site_perl/5.10.0/i686-linux-thread- +multi /home/sergei/PERL-5.10.0/lib/perl5/site_perl/5.10.0 . at ./father.pl line 8. cwd: /home/sergei/junk/perl_package PATH: /opt/kde3/bin:/home/sergei/bin:/usr/local/bin:/usr/bin:/bin:/usr +/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/jvm/jre/bin:/usr/lib/mit/ +bin:/usr/lib/mit/sbin $PATH[0]=/opt/kde3/bin at ./father.pl line 14. father.pl: $^X=/home/sergei/PERL-5.10.0/bin/perl at ./father.pl line 1 +6. father.pl: about to check Perl ($^X) at ./father.pl line 19. $cmd=/home/sergei/PERL-5.10.0/bin/perl -h at ./father.pl line 21. Usage: /home/sergei/PERL-5.10.0/bin/perl [switches] [--] [programfile] + [arguments] -0[octal] specify record separator (\0, if no argument) -a autosplit mode with -n or -p (splits $_ into @F) -C[number/list] enables the listed Unicode features -c check syntax only (runs BEGIN and CHECK blocks) -d[:debugger] run program under debugger -D[number/list] set debugging flags (argument is a bit mask or alp +habets) -e program one line of program (several -e's allowed, omit pr +ogramfile) -E program like -e, but enables all optional features -f don't do $sitelib/sitecustomize.pl at startup -F/pattern/ split() pattern for -a switch (//'s are optional) -i[extension] edit <> files in place (makes backup if extension +supplied) -Idirectory specify @INC/#include directory (several -I's allo +wed) -l[octal] enable line ending processing, specifies line term +inator -[mM][-]module execute "use/no module..." before executing progra +m -n assume "while (<>) { ... }" loop around program -p assume loop like -n but print line also, like sed -P run program through C preprocessor before compilat +ion -s enable rudimentary parsing for switches after prog +ramfile -S look for programfile using PATH environment variab +le -t enable tainting warnings -T enable tainting checks -u dump core after parsing program -U allow unsafe operations -v print version, subversion (includes VERY IMPORTANT + perl info) -V[:variable] print configuration summary (or a single Config.pm + variable) -w enable many useful warnings (RECOMMENDED) -W enable all warnings -x[directory] strip off text before #!perl line and perhaps cd t +o directory -X disable all warnings father.pl: $?=0 at ./father.pl line 23. ".
However, when run as packaged stand-alone script, it fails:
" (export PATH=/opt/kde3/bin:/home/sergei/bin:/usr/local/bin:/bin:/usr/X +11R6/bin:/usr/games:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mi +t/sbin;./father) this is father, $0=./father $^X=perl at script/father.pl line 7. father.pl: @INC= /tmp/par-sergei/cache-e0cd5bf94ffa04802f4f5c756f59f68f58993e95/inc/lib /tmp/par-sergei/cache-e0cd5bf94ffa04802f4f5c756f59f68f58993e95/inc CODE(0x8736488) CODE(0x87367d8) at script/father.pl line 8. cwd: /home/sergei/junk/perl_package PATH: /tmp/par-sergei/cache-e0cd5bf94ffa04802f4f5c756f59f68f58993e95:/ +opt/kde3/bin:/home/sergei/bin:/usr/local/bin:/bin:/usr/X11R6/bin:/usr +/games:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin $PATH[0]=/tmp/par-sergei/cache-e0cd5bf94ffa04802f4f5c756f59f68f58993e9 +5 at script/father.pl line 14. father.pl: $^X=perl at script/father.pl line 16. father.pl: about to check Perl ($^X) at script/father.pl line 19. $cmd=perl -h at script/father.pl line 21. father.pl: $?=-1 at script/father.pl line 23. "

- I intentionally modified $PATH _not_ to include paths to system-wide Perl.

So, where is Perl interpreter in the stand-alone executable ? Is it possible to use it to run child scripts ? Thanks, Sergei.

In reply to pp - where is the Perl interpreter ? by sergstesh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.