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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.