Welcome to the Monastery | |
PerlMonks |
Re: Containing 'use lib' statements in modules to their own namespaceby thargas (Deacon) |
on Oct 20, 2015 at 11:47 UTC ( [id://1145418]=note: print w/replies, xml ) | Need Help?? |
TL;DR: only modify @INC in the main script, not in modules. IMHO *modules* which modify @INC, either directly or via something like use lib ... are *bad*. They're bad enough when they're part of code you control (at least you'll know when you change them), but when they're part of someone else's code, they can cause all kinds of problems which can be very difficult to track down. Imagine that I'm using release 3.0.0 of Some::Module which I've included in my application's lib dir. Now imagine that some other module I'm forced to use modifies @INC so that release 4.0.0 of Some::Module is now in @INC ahead of my applications lib dir. Now imagine that release 4.0.0 is incompatible with release 3.0.0, but not in an obvious crash-your-program-now way, but something subtler. I don't permit this kind of thing where I have any control of the code base and I've written code similar in effect to shmem's suggestion to prevent such badly behaved code from changing @INC.
In Section
Seekers of Perl Wisdom
|
|