Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: pp: modules disappearing while program runs?

by swl (Parson)
on Apr 07, 2022 at 22:06 UTC ( [id://11142810]=note: print w/replies, xml ) Need Help??


in reply to Re^2: pp: modules disappearing while program runs?
in thread pp: modules disappearing while program runs?

You can localise the settings by wrapping your executables inside batch files, setting the env vars in the batch files, and calling the batch files instead of the executables. Whether it is practical for your system is another question, of course.

For example (untested):

set PAR_GLOBAL_TEMP=C:\some\path exe_name.exe %*

Another alternative it to write a wrapper script in perl that sets the environment and then calls the original exe. This script can be packed using pp, with the original exe added using --addfile. You will need logic in the wrapper script to determine if it is running under PAR and thus where it needs to look for the executable.

# also untested use Path::Tiny qw /path/; use FindBin qw /$Bin/; my $exe_name = 'some_exe'; my $exe_path; if ($ENV{PAR_0}) { # running under PAR - look for the unpacked exe f +ile $exe_path = path ($ENV{PAR_TEMP}, 'inc', $exe_name)->stringify; } else { # not running under par, assume file is adjacent $exe_path = path( $Bin, $exe_name )->stringify; } # set the env var $ENV{GLOBAL_PAR_TEMP} = 'C:\some\path'; # now run it # maybe use exec or wrap it in Capture::Tiny::capture system $exe_path, @ARGV;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11142810]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-03-28 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found