Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Loading the latest version of modules

by Anonymous Monk
on Jul 06, 2011 at 02:27 UTC ( #912902=perlquestion: print w/replies, xml ) Need Help??

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

Regarding my previous question about appending directories to @INC instead of prepending to it, I guess what I really want is for Perl to load the latest version of modules.

For deployment convenience, I ship CPAN modules with my application so that a minimum Perl installation can quickly run the application. In my application scripts I add "use lib '/path/to/bundled/cpan'". However, some of the included CPAN modules might get a bit out of date (I try to update the bundled CPAN as often as possible, but still...) and the system's CPAN module version might be newer.

What I would like is for Perl to keep searching entries in @INC and compare the versions of all modules found, and then use the latest one.

I know that doing this might open a whole can of worms (for example, the recent LWP 6.00 incompatibilities), but in general it has worked quite well so far in my case.

And I also would like to exclude this behaviour for some modules, since I also have a couple of patched CPAN modules that I want to use regardless of new version from CPAN.

Any ready-made solution I can use? Module::Load::* seems to be able to be slightly modified to do what I need, but I don't want to change all the "use" statements in my scripts/libraries. What would be ideal is probably custom hook in @INC.

Some imagined syntax:

use lib::latest "/path/to/bundled/cpan", "/another", -exclude => qr/^( +Email::Valid|LWP::protocol::)$/; # Foo::Bar should be searched in all @INC entries, and the latest vers +ion used use Foo::Bar; # the first found @INC is used, which will be in /path/to/bundled/cpan use Email::Valid;
ak

Replies are listed 'Best First'.
Re: Loading the latest version of modules
by AnomalousMonk (Archbishop) on Jul 06, 2011 at 02:44 UTC
    What would be ideal is probably custom hook in @INC.

    Don't know if this will help you, but that sentence triggered the memory of (see perlvar):

    @INC
    ...
    You can also insert hooks into the file inclusion system by putting Perl code directly into @INC. Those hooks may be subroutine references, array references or blessed objects. See "require" in perlfunc for details.
      Yep, I was hoping someone already wrote the hook code :)
Re: Loading the latest version of modules
by creamygoodness (Curate) on Jul 06, 2011 at 04:40 UTC

    It's hopeless. Give up.

    Module versioning in interpreted languages can't be solved until the version number becomes part of the package identifier:

    use aliased Foo3 => 'Foo';

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (1)
As of 2023-05-31 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?