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 reply to Re: Containing 'use lib' statements in modules to their own namespace by thargas
in thread Containing 'use lib' statements in modules to their own namespace by lgp171188

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.