If I make my own perl module, were do install it
As the resident "Perlmeister" where I work
I wrestle with that question all the time. There are
several options that I use depending on the situation:
Some preconditions to consider:
The first thing I have to say to pre-qualify all that I
am going to say on this subject is the fact we have a
convention where I work that all third party software
installed on our supported systems goes into
/usr/local/software and each software
package goes into its own subdirectory with some sort
of revision tag in its name. Example we would put
Perl version 5.8 into a subdirectory under
/usr/local/software/perl-5.8 with appropriate
symbolic links to places like
/usr/bin
and
/usr/lib etc. This makes it real easy
to deploy new versions of things onto our supported
systems and roll back if necessary and other options.
Application Specific Modules
Keeping that scheme in mind if I or someone on my team
has written a module specific to a patricular application
then that module is going to get installed in the
subdirectory that the application has been installed in.
For instance if I have an application called
"mailStripper" and its version number is
2.1 then it will get installed in
/usr/local/software/mailStripper-2.1
with its modules installed in
/usr/local/software/mailStripper-2.1/lib/perl5
and in subdirectories as appropriate. This means that I
have to tell the individual scripts for that application
where to find its modules. One of many ways of doing
this of course is:
use lib qq(/usr/local/software/mailStripper-2.1/lib/perl5);
The weakness of doing that keep in mind is that if I change
the version of the application and it gets installed
somewhere else I have to make sure I update the
use line as appropriate.
Still local, but I don't want to mix it into Perl's installation directory
Still keeping in mind the scheme we are using for
installing third party software there are cases where I
want to make locally developed modules available to
multiple applications. We will install those in a
directory
/usr/local/software/lib/perl5.
Again you need to do the
use lib ... thing
in scripts using those modules.
Put in with the rest of the modules!
If you really insist on not dealing with putting
use lib... in your scripts to get to your
modules then you can always do a
perl -e "print join($/,@INC);"
and see where Perl expects to find modules and put
your stuff in there. The burden you now have is to
keep track of what you put there in the event you
upgrade Perl and have to re-install your modules.
TIAMTOWTDI in Perl...
Peter L. Berghold -- Unix Professional Peter at Berghold dot Net |
| |
Dog trainer, dog agility exhibitor, brewer of
fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and
a good Belgian ale in your chalice. |