Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hello,

thank you for all your links. They were very interesting. In the meantime I tried cava packager which is also a good packaging tool.

But I like it to solve problems. And I like the one file concept of pp and so I did not give up. And now I have found the complete solution.

  1. pp -p -B -o packed_script.par main_script.pl helper_script.pl
  2. Add the file "main.pl" to "packed_script.par" in the script folder where now also are "main_script.pl" and "helper_script.pl".

    main.pl

    if (defined $ENV{PAR_APP_REUSE}) { my $filename = $ENV{PAR_APP_REUSE}; delete $ENV{PAR_APP_REUSE}; $ENV{PAR_0} = $filename; PAR::_run_external_file($filename, 1); exit(); } my $zip = $PAR::LibCache{$ENV{PAR_PROGNAME}} || Archive::Zip->new(__FI +LE__); my $member = eval { $zip->memberNamed('script/main_script.pl') } or die qq(main.pl: Can't open perl script "script/main_script. +pl": No such file or directory ($zip)); PAR::_run_member($member, 1);
  3. pp -o  packed_script --reusable packed_script.par

Here how to call the external helper script from the main script:

############################################################# # part in the main_script.pl where the helper script is invoked ############################################################# my $cmd; if( defined $ENV{PAR_TEMP} ) { $cmd = "$0 --par-options --reuse $ENV{PAR_TEMP}/inc/script/helper_ +script.pl"; } else { $cmd = "perl helper_script.pl"; } # invoke cmd

Now the main script and another external script "helper_script.pl" are packed in one standalone executable. It is running without the need of a perl installation. And all needed modules are packed.

Feedback to this solution is welcome.

Cheers, Dirk


In reply to Solution - pp and multiple perl scripts by Dirk80
in thread pp and multiple perl scripts by Dirk80

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-25 19:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found