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

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/ exists, then Perl will not look for, nor care about the existence, of /opt/custom/lib/This/Here/" 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[]}; ' version: 2.23 location: /usr/foss/packages/perl/perl-5.20.3/lib/5.20.3/ --> perl -E 'use lib reverse @INC; use autodie; say q[version: ], $autodie::VERSION; say q[location: ], $INC{q[]};' version: 2.29 location: /usr/foss/packages/cpan-basics/perl-5.20.3/lib/perl5/autod --> perl -E 'use autodie 2.29; say q[version: ], $autodie::VERSION; say q[location: ], $INC{q[]}; ' 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.