http://www.perlmonks.org?node_id=1010468

vsespb has asked for the wisdom of the Perl Monks concerning the following question:

I want to distribute perl command line program (say myscript.pl in myscript.zip), which split into several modules. Some modules are really useful and I am going to publish it in CPAN (for example one of them is Net::MyModule).

myscript.zip can come with installer (or have myscript.deb/myscript.rpm in it) which installs all modules into global location.

I am wondering how to deal with possible conflict of Net::MyModule from CPAN and Net::MyModule from myscript.zip ( myscript.deb ) ?

Obvious solution is 1) distribute myscript.zip without Net::MyModule 2) Publish Net::MyModule on CPAN 3) Ask/force users to install Net::MyModule from CPAN

But I don't want' to do that currently as myscript.zip works without external dependencies (except Core modules) with any perl version higher that 5.8.8. So I don't want bother non-Perl users to install something using CPAN ( I wan't easier deploy ). Another reason is that I might want to fix something it Net::MyModule and make it immediatelly available with new version of myscript.zip

What are options here?

Replies are listed 'Best First'.
Re: Spliting own program distribution intoi several modules.
by tobyink (Canon) on Dec 27, 2012 at 09:35 UTC

    Maybe take a look at App::FatPacker which allows you to inline all the modules used by myscript.pl into myscript.pl itself. This way myscript.pl always gets the exact versions of its required modules that are inlined within it, even if newer/older versions are available.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
      Yep, that looks like a solution..
Re: Spliting own program distribution intoi several modules.
by Corion (Patriarch) on Dec 27, 2012 at 08:46 UTC

    One way would be to add your private module path before the CPAN module path in @INC so that Perl will prefer local module installations over installations from CPAN:

    BEGIN { my $private_module_path = '/usr/local/myscript/lib'; unshift @INC, $private_module_path; }; use Net::MyModule; # will pick up the first Net/MyModule.pm that is fo +und in @INC

    An alternative approach would be to load both modules and then try to find out which one has the largert version number, but that is a hairy thing to try and a user who does local modifications might not think of bumping the version number high enough.