g_speran has asked for the wisdom of the Perl Monks concerning the following question:

Hello All, I Am trying to use par packer to create and executable. However I am struggling to get the results I am looking for.

So I try the following: This creates the switch.exe file and adds the #defaultconfig In the exe but when the exe is executed, I get an error that it can not find the switch script. When I examine the contents of the exe, the dell4048.pl and #defaultconfig files are indeed in the script directory. So it seems that the name of the exe needs to be the same name of the script minus the extension.

So I try the following instead:

When the switch.exe runs, it properly launches the dell4948.pl script but upon examination of the switch.exe file, only the dell4048.pl file is located under the script directory. The #defaultconfig file is not in the script directory

So, how can I get pp to create the switch.exe file, include the #defaultconfig file and when switch.exe is executed, it will run the dell4048.pl script within script.exe ?

Thanks,

Gary

Replies are listed 'Best First'.
Re: Par Packager - executable
by swl (Prior) on Mar 14, 2019 at 03:57 UTC

    Is #defaultconfig a literal file name? Or are you using it as a placeholder in your post?

    In any case, storing files within the packed executable (zip file) is done using the --addfile switch. Details are in the documentation: pp

    Files packed in this way are located in the inc directory under $ENV{PAR_TEMP} when unpacked, and your script can look for it there.

    Some example code to handle both packed and not packed scripts is below.

    # get the default config file if ($ENV{PAR_0}) { # we are running under PAR my $path = Path::Class::file ($ENV{PAR_TEMP}, 'inc', ''); my $path_str = $ui_path->stringify; ... } else { ... }
      Yes.... #defaultconfig is the actual file name
Re: Par Packager - executable
by kcott (Archbishop) on Mar 14, 2019 at 10:57 UTC

    G'day g_speran,

    As ++swl hinted, you may be commenting out the argument.

    Arguments with no hashes:

    $ perl -E 'say "Args (@ARGV): ", 0+@ARGV' A B C Args (A B C): 3

    Arguments commented out with hash:

    $ perl -E 'say "Args (@ARGV): ", 0+@ARGV' #A B C Args (): 0

    Arguments with an escaped hash to prevent commenting:

    $ perl -E 'say "Args (@ARGV): ", 0+@ARGV' \#A B C Args (#A B C): 3

    — Ken

      # is a valid file name character on windows, and comments start with two colons ::. That said, the OP does not specify which OS they are using...

Re: Par Packager - executable
by dasgar (Priest) on Mar 14, 2019 at 16:53 UTC

    This doesn't address the issue that you're trying to resolve, but I'd recommend adding the -x option when using pp to help "determine additional run-time dependencies". Personally, I always add in the -x option just to help avoid issues.