Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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

In reply to Loading the latest version of modules by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2023-10-01 02:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?