How does the Perl lib pragma work?

I use use lib "./DIR"to grab a library from a folder elsewhere. However, it does not work on my server, but it works fine on my local desktop. Any specific reasons?

And one more question: is it distributed use libin several modules?

Two situations: Let's say I am making a base class that requires several libraries, but I know that it needs to be extended, and the extended class will need to use another library. Can I put a command use libin a base class? or will I need to put it in every extensible class?

Finally, can I just have use packagewhere the package contains a bunch of lib usage, will it propagate lib usage statements to my current module? <- I don’t think so, but I ask anyways

+5
source share
2 answers

.in your statement use libmeans "current working directory" and will only work when your script is run from the correct directory. The idea of ​​a cwd server is probably something else (or undefined). Assuming the library directory is shared with the script and closed for it, you want to do something like this:

use FindBin;
use lib "$FindBin::Bin/DIR";
Operator

A use lib @INC - perl , use require . . use lib , .

, package MyLibs, use lib, use MyLibs , .

+3

, . , @INC -, , .

use lib @INC, , use lib, , , include.

@INC . perlvar.

+2

All Articles