Where can I install the Perl modules I wrote?

I wrote several modules and tried to run them. How can I tell where to get the module?

I am writing on Windows and trying to put it in c:\perl\lib, but that did not help.

Is it possible to put it in the same directory as the file that calls the module?

+3
source share
3 answers

Perl uses paths in:

@INC

to search for modules. (.pm files)

If you:

perl -e 'print join "\n", @INC;'

You will see which paths are currently being searched for modules. (This @INC list is compiled into the perl executable)

Then you can:

BEGIN { unshift @INC, 'C:\mylibs' }

or

use lib 'C:\mylibs'

and put MyModule.pm inside C: \ mylibs to include:

use MyModule;
+13
source

, local::lib . use local::lib; ~/perl5 (@INC), , .

( ), , , use lib 'PATH'.

, , PERL5LIB, . Perl, , Perl , (, -), , , PERL5LIB .

@INC. .

+6

, , FindBin, , use lib - @INC:

use FindBin;
use lib "$FindBin::Bin/lib";
use AppModule;

, CPAN (, module-starter) perl ( site/lib). : ?

perl (.. ), . . /? perlfaq8.

+4

Source: https://habr.com/ru/post/1724923/


All Articles