I would inquire of the monks: What are the best practices for storing locally generated libraries?

Background: I write a lot of perl functions that are used by local programs and for obvious reasons I keep them in library files somewhere in my home directory for reuse. These are not CPAN functions, just lots of things I have written over time and that are useful to my workflow.

I do work across several machines, and some of the programs need configuration parameters (think: IP addresses, usernames, port assignments and the like) so I also had a file "~/.config/perl/SiteConfig.pm" that exposes a hash of various bits of information of that nature.

I set PERL5LIB so that any program I ran could access these libraries and everything worked well enough.

All of this went horribly wrong when I went to apt-get install something as superuser - the root login carries over the PERL5LIB from the base user, and some of my files conflicted with system ones and the entire install process got borked. (Clearing PERL5LIB in root/bashrc fixes the problem, but doesn't fix the broken installs.)

So my question is: what is the *preferred* placement and configuration for locally generated libraries and programs specific to a login?

For instance, I have a directory "Math" containing several files "EM.pm", "Levy.pm", "Log2.pm", and so on. Should I place my library dirs in a subdir "Site" so that I have to "use Site::SomeDir::SomeLib" for each library, to avoid namespace conflicts? Should I use the -I option on all shebang lines with a specific directory, or is it better to use PERL5LIB?

And is there a standard place (in my home directory) to put the directories containing the library files? For example, is .config/perl/ the right place for a shelf of library dirs?

What is "best practices" for this sort of setup?

A related question is where to put executable perl programs that are specific to my login. Is there a "bin" directory position within my home directory that's seen as standard or typical?


In reply to Best practices for local libraries by Barrabas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.