Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl Programming and Distribution

I'm very new to Perl programming. I've just finished reading the Llama book. Up until now I have scripted in Bash, but I'm wanting to try out Perl and it's benefits over Bash scripting.

I'm creating a script that uses a number of standard modules (e.g. Getopt) and some not-so-standard modules (e.g. PerlMagick)

At some point I want to distribute my Perl code and I want it to be usable by people who don't really know about Perl or programming. Obviously the standard modules should always be there (I'm using "use 5.010" to guarantee this to a certain extent), but what of the non-standard ones?

I guess there are two possibilities: 1) Should I tell the end user to install the missing modules? 2) Should I create an installation script that tests for the modules and if they are not there, then install them? If choice 2 is chosen, should I download the modules and install them? Or distribute them with my main code? I'm just not sure what the etiquette is with such things...

Thank you very much for all advice, Ben

like image 427
forquare Avatar asked Jul 12 '10 23:07

forquare


1 Answers

If you design your app as a Perl distribution (as used on CPAN), then you get the power of the Perl toolchain to deal with this kind of thing for you. You just make sure that the modules you depend on are listed properly in your Makefile.PL, and then someone only has to write cpan YourApp::Name to get your application and everything it requires. Or if they downloaded your app from somewhere other than CPAN and they're building it manually, the make process can find the dependencies for them (which is why Module::AutoInstall isn't entirely dead and doesn't deserve to be IMO).

For Windows users, the only thing you have to add before the cpan YourApp::Name step is "install Strawberry Perl".

You also have the option of bundling (whether that involves PAR or just an installer or archive that includes both your app and all of the necessary modules, and probably perl itself) but there's one major drawback to that technique: it means you either can't use any XS code, or else you have to provide a separate package for each different platform that you want your app to support. The CPAN route doesn't run into that problem.

like image 74
hobbs Avatar answered Sep 18 '22 18:09

hobbs