Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Beginner - difference between lib directories in Perl install

by Anonymous Monk
on Oct 16, 2010 at 16:08 UTC ( [id://865684]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi

Please can you tell me what is the difference between the 2 lib directories in my Perl installation? I have c:\Perl\lib and C:\Perl\site\lib. If I were to write my own modules, which lib directory should I put them in?

Many thanks in advance
  • Comment on Beginner - difference between lib directories in Perl install

Replies are listed 'Best First'.
Re: Beginner - difference between lib directories in Perl install
by Utilitarian (Vicar) on Oct 16, 2010 at 16:46 UTC
    Modules you write yourself should go in the site directory as their are particular to this site.

    print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
Re: Beginner - difference between lib directories in Perl install
by kcott (Archbishop) on Oct 16, 2010 at 20:22 UTC

    You may also see a vendor/lib directory which holds modules written by a third party. It looks like you have ActivePerl installed: it's possible you might get one of those using PPM to install a non-ActiveState module.

    I have one with my Strawberry Perl installation:

    C:\_\tmp>perl -V ... @INC: C:/strawberry/perl/site/lib C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib

    You may come across other variations such as this from my Cygwin installation (which uses site_perl instead of site):

    $ perl -V ... @INC: /usr/local/lib/perl5/site_perl/5.12.0/cygwin-thread-multi-64int /usr/local/lib/perl5/site_perl/5.12.0 /usr/local/lib/perl5/5.12.0/cygwin-thread-multi-64int /usr/local/lib/perl5/5.12.0

    -- Ken

      You may also see a vendor/lib directory which holds modules written by a third party.

      vendors are those who build and distribute perl binaries, (ActiveState/Strawberry Perl/Redhat)...

      modules which vendors add to the standard perl distribution get installed into vendor directories (sometimes vendors reuse site directories).

      Modules you (or your admin) install go into site directories.

      Modules installed in privlib are those which come with perl (core modules).

      $ perl -V:install.* installarchlib='D:\strawberry\perl\lib'; installbin='D:\strawberry\perl\bin'; installhtml1dir=''; installhtml3dir=''; installhtmldir=''; installhtmlhelpdir=''; installman1dir=''; installman3dir=''; installprefix='D:\strawberry\perl'; installprefixexp='D:\strawberry\perl'; installprivlib='D:\strawberry\perl\lib'; installscript='D:\strawberry\perl\bin'; installsitearch='D:\strawberry\perl\site\lib'; installsitebin='D:\strawberry\perl\site\bin'; installsitehtml1dir=''; installsitehtml3dir=''; installsitelib='D:\strawberry\perl\site\lib'; installsiteman1dir=''; installsiteman3dir=''; installsitescript='D:\strawberry\perl\site\bin'; installstyle='lib'; installusrbinperl='undef'; installvendorarch='D:\strawberry\perl\vendor\lib'; installvendorbin='D:\strawberry\perl\bin'; installvendorhtml1dir=''; installvendorhtml3dir=''; installvendorlib='D:\strawberry\perl\vendor\lib'; installvendorman1dir=''; installvendorman3dir=''; installvendorscript='D:\strawberry\perl\bin';
Re: Beginner - difference between lib directories in Perl install
by Your Mother (Archbishop) on Oct 16, 2010 at 22:59 UTC

    It can be difficult/confusing if you're not used to it but you should put them in neither. You should make a code repository (anywhere you like) tracked by git or svn or something you like and then create module distributions which you install with tools like cpanm or CPAN::Inject. They will put the modules wherever your Perl installation believes they belong.

    The resulting destination is likely to be the site/lib but this way you won't have to worry about it, you'll have repeatable steps to install it on any machine you want, and you'll be able to roll back to a previous version if you hose your code.

    Update: if you're really a beginner and not technically gifted that advice might not be helpful at all but the basic advice doesn't change. The easiest way is still to do neither but use lib to use your module code and keep it next to (in the same dir or in a ./lib) your script.

Re: Beginner - difference between lib directories in Perl install
by Anonymous Monk on Oct 16, 2010 at 16:46 UTC

    i think this is the answer to my question: CORE modules are installed under perl/lib whereas non-CORE modules install under perl/site/lib.

      Almost there: the modules that came with your original installation go into lib. Newer versions go into site/lib. At least on ActiveState Perl and Strawberry Perl, both on Windows, that is.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-20 01:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found