Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Spliting own program distribution intoi several modules.

by vsespb (Hermit)
on Dec 27, 2012 at 08:35 UTC ( #1010468=perlquestion: print w/ replies, xml ) Need Help??
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?

Comment on Spliting own program distribution intoi several modules.
Re: Spliting own program distribution intoi several modules.
by Corion (Pope) 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.

Re: Spliting own program distribution intoi several modules.
by tobyink (Abbot) 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..

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1010468]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2014-08-23 20:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls