I use use lib "./DIR" to grab a library from a folder elsewhere. However, it doesn’t seem to work on my server, but it works fine on my local desktop.
Any particular reasons?
And one more question, does use lib get propagated within several modules?
Two situations:
Say I make a base class that requires a few libraries, but I know that it needs to be extended and the extended class will need to use another library. Can I put the use lib command in the base class? or will I need to put it in every extending class?
Finally, can I just have a use package where package contains a bunch of use lib, will it propagate the use lib statements over to my current module? <– I don’t think so, but asking anyways
The
.in youruse libstatement means “current working directory” and will only work when your script is run from the right directory. The server’s idea of cwd is probably something different (or undefined). Assuming that the library directory is co-located with with script and private to it you want to do something like this instead:A
use libstatement affects@INC— the list of locations perl searches when youuseorrequirea module. It globally affects the current instance of the interpreter. You should really only putuse libstatements in scripts, not in modules.In principle, you could have a
package MyLibsthat consisted of a bunch ofuse libstatements and thenuse MyLibsbefore using any of the packages in those locations, but I wouldn’t recommend it.