|Just another Perl shrine|
Best practices for local librariesby Barrabas (Novice)
|on Dec 07, 2019 at 04:11 UTC||Need Help??|
Barrabas has asked for the wisdom of the Perl Monks concerning the following question:
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?