Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

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

I curate a repository of cpan modules @WORK that is shared across the enterprise. Unfortunately, I am trying to serve two masters: "run the biz" and "change the biz". The RTB folks don't like changes to their environment, and fight vehemently when modules upgrade (b/c they have production systems dependent upon old code). By contrast, the CTB folks love the bleeding edge and want to try new things, build new tools, etc.

So, when I built Perl for the next operating system, I added a new directory to the default @INC where I can put additional, non-core, modules (or new versions of existing modules) for the CTB folks. This works fine if the "newer version" of a module comes earliest in the @INC list. But what happens when something in the corelist is updated? DHOH!

So after much GIYF, I found this very troubling statement:

"Please recall that Perl interpreter will STOP trying to search [additional directories in @INC] once it finds the file in one of the locations, without trying to see if the file is in later locations as well. E.g. if /usr/lib/perl/This/Here/MyModule2.pm exists, then Perl will not look for, nor care about the existence, of /opt/custom/lib/This/Here/MyModule2.pm." Stack Overflow

Is there a better solution than "use lib reverse @INC" to get the newer module that is further in the @INC list?

For example, autodie v.2.23 is in the core for perl. So I build the newest autodie v.2.29, and it now lives in the non-core extras modules path, which is part of the default @INC.

--> perl -MData::Dumper -E 'say "INC: ", Dumper( \@INC )' INC: $VAR1 = [ '/usr/foss/packages/perl/perl-5.20.3/lib/site_perl/5.20.3/x8 +6_64-linux-thread-multi', '/usr/foss/packages/perl/perl-5.20.3/lib/site_perl/5.20.3', '/usr/foss/packages/perl/perl-5.20.3/lib/5.20.3/x86_64-linux +-thread-multi-ld', '/usr/foss/packages/perl/perl-5.20.3/lib/5.20.3', '/usr/foss/packages/cpan-basics/perl-5.20.3/lib/perl5/x86_64 +-linux-thread-multi-ld', '/usr/foss/packages/cpan-basics/perl-5.20.3/lib/perl5', '/usr/foss/packages/cpan-basics/perl-5.20.3/lib/perl5/site_p +erl', '/usr/foss/packages/foss-perllib', '.' ]; --> perl -E 'use autodie; say q[version: ], $autodie::VERSION; say q[location: ], $INC{q[autodie.pm]}; ' version: 2.23 location: /usr/foss/packages/perl/perl-5.20.3/lib/5.20.3/autodie.pm --> perl -E 'use lib reverse @INC; use autodie; say q[version: ], $autodie::VERSION; say q[location: ], $INC{q[autodie.pm]};' version: 2.29 location: /usr/foss/packages/cpan-basics/perl-5.20.3/lib/perl5/autod +ie.pm --> perl -E 'use autodie 2.29; say q[version: ], $autodie::VERSION; say q[location: ], $INC{q[autodie.pm]}; ' autodie version 2.29 required--this is only version 2.23 at -e lin +e 1. BEGIN failed--compilation aborted at -e line 1.

So again, I ask: is there a better solution than "use lib reverse @INC" to get the newer module that is further in the @INC list? Is there a way to change the module search heuristic in Perl so that all the locations are scanned when you specify a VERSION (and/or a LIST)? Am I missing a new feature that solves this problem?

TIA for your wisdom and insights.


In reply to how to improve: use MODULE VERSION LIST by smile4me

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 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 wandering the Monastery: (3)
As of 2021-08-02 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)








    Results (27 votes). Check out past polls.

    Notices?