Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I detect if a program is running within a PAR archive?

Tags:

zip

perl

par

I'm working on a large Perl application which gets bundled with PAR, along with a bunch of support files.

When the app is running within PAR, I can use PAR::read_file to get at these various files inside the archive. However, while I'm developing, I don't want to have to re-PAR the whole application every time I tweak some code.

Is there a way that I can tell if the script is running within PAR or not at runtime, so I can choose to load the file from the PAR archive or the regular filesystem?

like image 262
friedo Avatar asked Mar 01 '23 00:03

friedo


1 Answers

PAR::Environment can probably offer some clues:

PAR uses various environment variables both during the building process of executables or PAR archives and the use of them.

...

PAR_0

If the running program is run from within a PAR archive or pp-produced executable, this variable contains the name of the extracted program (i.e. .pl file).

like image 164
Sinan Ünür Avatar answered Mar 06 '23 04:03

Sinan Ünür