Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distribute native perl scripts without custom module overhead?

How can someone distribute native (non-"compiled/perl2exe/...") Perl scripts without forcing users to be aware of the custom (non-CPAN) modules that the scripts needs in order to run?

The problem is users will inevitably copy the script somewhere else on the system and take the script out of its native environment and then it can no longer find the modules it needs to run.

I've sometimes settled with just copying the module into the actual script, but I'd prefer a cleaner solution.

Update: I better clarify. I distribute a bunch of scripts which happen to use similar modules in the backend. The users understand how to run Perl scripts, but rather than relying on telling them "no don't move the script" I'd prefer to simply allow them to move the files. The path of least resistence.

like image 461
dlamotte Avatar asked Nov 10 '09 18:11

dlamotte


3 Answers

The right way is to tell them "Don't do that!" I would hope that they wouldn't expect to move an exe file and have the program continue to work. This is no different.

That said, there are a couple of alternatives. One is replacing the script with a wrapper (e.g. pl2bat) that knows the full path to the real script. Another is to use PAR, but that would require PAR and/or parl (from PAR::Packer) to be installed.

like image 127
Michael Carman Avatar answered Nov 19 '22 08:11

Michael Carman


If a script that your prepared for a client needs "custom" modules, simply pack your modules as if you were trying to upload them to cpan. Then give the package to the client and he can use the cpan utility to install the script and the modules.

like image 42
innaM Avatar answered Nov 19 '22 08:11

innaM


Distribute an installer along with the script. The installer will need to be run with root privileges and it will put the custom modules into the standard system location (/usr/local/lib/perl5/site_perl or whatever).

I've not tried this, but Module::Install looks helpful in this regard. It's described as a:

Standalone, extensible Perl module installer

like image 2
Ben Dunlap Avatar answered Nov 19 '22 09:11

Ben Dunlap