Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Containing 'use lib' statements in modules to their own namespace

by thargas (Deacon)
on Oct 20, 2015 at 11:47 UTC ( [id://1145418]=note: print w/replies, xml ) Need Help??


in reply to Containing 'use lib' statements in modules to their own namespace

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1145418]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-03-29 15:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found