How to redistribute non-core modules in Perl?

I'm relatively new to Perl and I need help redistributing non-core modules. Here is the whole story.

There are two non-core modules in a Perl script: XML :: Simple and SOAP :: Lite . The version I'm using (currently on Windows) is Strawberry Perl, so these two modules are already included. However, we do not know if these end users (Unix / Linux system) have these two modules, since they can only have the standard version and therefore only have the main modules. My goal is to make end users the maximum possible configurations / settings.

First, I tried to find out if there are any kernel modules similar to XML :: Simple and SOAP :: Lite . Unfortunately, I did not find (please correct me if I am wrong).

So, I think, now the only option is to redistribute the two modules. I checked and that these two modules allow redistribution. My problem right now is how to do this. I tried the keyword search for "perl redistribute" but did not find anything useful. I guess we are using an exporter tool to achieve this. but these two modules are rather complex modules and they have several sub folders / pm files (and a whole bunch of other files like MAKE, pod, ini files), so I'm not sure what I should do. The examples I found using the exporter are quite simple: they only have a file in 1 hour and 1 file pl, and they are placed in one folder.

In addition, I am open to any other best ways to solve this problem. The goal is to make sure that all end users can use my script with minimal setup / installation efforts, since we do not want them to encounter a number of compatibility issues.

Any help would be greatly appreciated. Thanks! = D

+4
source share
3 answers

One of the best things about Perl is CPAN, Perl’s comprehensive archives network. This is a mirroring service that, since Perl 5 was originally released, has allowed people to share useful add-ons, such as XML::Simple or SOAP::Lite , using the standard, common tool cpan client that comes with Perl. Almost all Perl distributions (such as Strawberry Perl and most Perl distributions shipped with Linux) have a CPAN client that is configured and included in it. This client allows people to download and install modules from CPAN just by knowing the name of the module.

Almost all CPAN module distributions correspond to the exact layout. Usually they have a Makefile.PL file (if it uses ExtUtils :: MakeMaker to generate a script installation file), Build.PL (if it uses Module :: Build to generate a script installation), or both. These Perl scripts, after starting, create a "Makefile" or "Build" file that allows you to install the module and make sure that all the necessary conditions are met.

If you've never done a Perl distribution before, you can download any distribution from CPAN and see how it went. Folders and file locations are pretty intuitive as soon as you notice them. They are usually installed with a script installation file and supporting files (for example, readme) in the root directory with custom modules (the modules you make) in the lib directory and with unit tests in the t directory.

I would recommend looking at Build.PL if you are a beginner; these are pure Perl-based installation scripts. If you decide to create a distribution based on Module.PL, it is very easy to indicate that XML::Simple and SOAP::Lite are needed to distribute your module. First, create a basic installation based on the :: Build script module. It looks something like this:

 use Module::Build; my $build = Module::Build->new( module_name => 'Foo::Bar', license => 'perl', requires => { 'perl' => '5.6.1', 'Some::Module' => '1.23', 'Other::Module' => '>= 1.2, != 1.5, < 2.0', }, ); $build->create_build_script; 

(This is taken directly from Module :: Build :: Authoring docs).

Then specify the required libraries and their minimum versions. Zero (0) is an acceptable version if you don't care, but that means “everything” is good. I would recommend specifying at least the version of libraries installed on the machines under test.

(A clear abbreviation: you can find out the version of any library that has the $ VERSION package variable set with:

 perl -MSome::Lib -E "say Some::Lib->VERSION()" 

.)

To install the module, the steps look something like this:

 cd folder\where\my\lib\is perl Build.PL Build Build test Build install 

This will create an installation tool, prepare a folder for testing (usually just copy the material to the assembly library area for simple modules), run all the .t scripts in the t folder (the “tests” that Test::More usually use for unit unit testing before installation), and then finally install your module in the libraries of your PC on Perl.

Build script, as part of the “configure things” phase, will review your premises and alert you if you do not already have them.

Then, as pointed out by ikegami's answer, if you use the cpanm client to install your library, the cpan client will automatically exit, download, verify and install its dependencies for you! Alternatively, installers based on Build.PL also have the option "installdeps", which will do the same. Then, any and all dependencies (and potentially recursive dependencies) are automatically downloaded, tested, and installed, even if they change in the future.

+3
source

I want to talk a little about @ikegami.

SOAP :: Lite has a large number of CPAN dependencies , so the people who install your module need CPAN access to create it, regardless of whether you provided them for them or specified them as a dependency. Otherwise, you will need to provide all of your dependency tree, after which you will end up using perlbrew, perhaps a box, maybe local :: lib, and then you can decide that you need the next higher level and create an RPM and DEB.

It's probably best to just provide your script packaged as a CPAN module, list your dependencies inside and let the chips fall where they can.

+5
source

Just specify the dependency on the modules in Makefile.PL or Build.PL, and then give them the following installation instructions:

 cpanm script.tar.gz 
+4
source

All Articles