Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Placement of custom modules outside of home directory?

by mldvx4 (Friar)
on Aug 22, 2022 at 10:30 UTC ( [id://11146291] : perlquestion . print w/replies, xml ) Need Help??

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

I have some homemade perl modules which have resided in my home directory so far. Lately they have outgrown that since they are being used by more than myself, thanks to help and advice from Perl Monks over time. Now I reckon they need to move out of my home directory to somewhere more appropriate within the file system hierarchy. They are still under somewhat active development, but the changes tend to be small and or incremental. What would be the best location for them to go next? Should they go in /usr/local/lib or somewhere else? And should perl5 be somewhere in the path name?


Replies are listed 'Best First'.
Re: Placement of custom modules outside of home directory?
by Discipulus (Canon) on Aug 22, 2022 at 11:00 UTC
    Hello mldvx4,

    I never had the chance to do this but about the name I suppose everything is good as long the path tell you and others something, like: /usr/local/lib/perl5/custom_modules (maybe better path names will come out from other monks who work on lucky OSs)

    You can be interested in how-to-change-inc-to-find-perl-modules-in-non-standard-locations and in perlfaq about PERL5LIB

    > They are still under somewhat active development..

    A separate path for them is mandatory in my opinion: you can have two paths dev and prod never touching the latter until you are sure all your tests (do you have tests, dont you?) passes.


    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      Keeping the development version and the latest production version separate is a good point, and the tests too. Unfortunately there is not a way to do automated testing on most of it. It has gotten complex enough that at least a written checklist is warranted.

Re: Placement of custom modules outside of home directory?
by karlgoethebier (Abbot) on Aug 22, 2022 at 18:02 UTC

    According to the exegesis as described in Filesystem Hierarchy Standard the stuff belongs to /usr/local/lib or /opt. You might consider a layout with a "dummy" or "functional" user and the corresponding group with her own home. E.g. like user oracle in group oracle with the home in /opt/oracle.

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

      Thanks, Karl, and everyone.

      I've put the production version under /usr/local/lib/perl5/ and placed a corresponding use lib ... in the scripts.

Re: Placement of custom modules outside of home directory?
by kcott (Archbishop) on Aug 23, 2022 at 06:44 UTC

    G'day mldvx4,

    [In the following, to avoid wrapping, I replaced /home/ken/perl5/perlbrew/perls/perl-5.36.0 with just /PB.]

    All of my modules are in one of these directories:

    $ perl -E 'say for @INC' /PB/lib/site_perl/5.36.0/cygwin-thread-multi /PB/lib/site_perl/5.36.0 /PB/lib/5.36.0/cygwin-thread-multi /PB/lib/5.36.0

    If you run that command, you should get a similar list. Unless you're running Cygwin, you won't have "cygwin-thread-multi". You may additionally have paths with "vendor". The point being that I have all of my modules in @INC directories; not doing this means repeatedly having to add use lib ... statements to many scripts.

    To achieve this, I just run the standard incantation:

    perl Makefile.PL make make test make install

    I let Perl add the module code in appropriate places and don't have to think about it any further.

    There are a variety of other ways to do this. These seem to be popular, although I don't use them: Module::Build and local::lib.

    So, my recommendation would be to pick a method for installing your modules and use it consistently. Let Perl do most of the work for you. :-)

    I've no idea how you develop your modules. If you're doing all the work manually, you may want to look at automating some of it (again, letting Perl work for you). You might want to ask about that separately.

    — Ken