I have used Par::packer (specifically, the pp utility) to create standalone executables in the past. This is the first time I need to reference other files. My question really is two fold:

  1. How to reference a file included with --addfile myfile.txt option? The partial answer is that any file which is included in the stand-alone executable is placed in $ENV{PAR_TEMP}/inc directory. So, when running the EXE, I can get at the included file using that path. However, how can I make access to that file universal from both EXE and when running the script through the Perl interpreter (perl foo.pl myfile.txt) ?
  2. My EXE has the following in it
    unless (my $return = do $script) { warn "could not parse $script: $@" if $@; warn "could not pull in $script: $!" unless defined $return; warn "could not execute $script" unless $return; }
    and $script is a user specified argument (a la $ARGV[0]). When I run this directly through the interpreter, my pwd is the directory where I am currently located, so that the relative path to $ARGV[0] is correct. However, when I run the pp'd EXE, the pwd is the PAR directory and the relative path to $ARGV[0] is no longer correct. How can I reconcile that?

As always, thanks in advance!

P.S. I know the risks of do(tainted_input), but because this tool is intended for internal distribution only, safety is not a concern.


In reply to Par::Packer and paths by gri6507

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.