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

I've created a Perl module for logging in some errors, my question is about where would be the best and safest place to place this module, I have it installed in (This is Windows, sorry) C:\Perl\Lib, but I have seeing installs done in C:\Perl\Site\Lib, is in there better just in case someone updates Perl and everything inside C:\Perl\Lib gets wiped out? I just want this module to be called as simple as:
use MyModule.pm
Thanks for the help!

Replies are listed 'Best First'.
Re: Perl Module Question
by rinceWind (Monsignor) on Jan 24, 2006 at 16:24 UTC

    C:\Perl\Site\Lib in general is the place where ActiveState Perl stores additional CPAN modules, whether the installation was done with PPM, CPAN(PLUS) or nmake install (i.e. by hand).

    If there is any likelyhood of a name clash between your code and CPAN modules, you could get into hot water. It's also worth considering using the standard CPAN mechanism: ExtUtils::MakeMaker or Module::Build for packaging up your modules, even if you never intend to publish them onto CPAN. This will give you the benefit of a nice standard installation procedure, and a way of bundling unit tests with your modules. If you do this, you no longer need to know or care where nmake install puts the modules, as this is defined in your Perl installation.

    See also:

    --

    Oh Lord, won’t you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, won’t you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)

Re: Perl Module Question
by holli (Abbot) on Jan 24, 2006 at 15:37 UTC
    You can create a directory like c:\perl\mylibs and set the PERL5LIB environment variable. You can then put your modules there and perl will find them.
    You can even create this directory on a shared device/network drive, so every machine in the network can access them without installation.


    holli, /regexed monk/
      Just have to create a directory called like Error inside of the c:\perl\site\lib\ and place the module in there.
      It can be called in the programs like,
      Error::YourModule;
Re: Perl Module Question
by monkey_boy (Priest) on Jan 24, 2006 at 15:23 UTC
    In unix/linux, i generally put my modules physically somewhere not in the perl directories (e.g. my home area), then symlink this directory to the perl/lib/site_perl/ directory. This way, my version is safe from being deleted by another perl install and when i make changes to my copy , i dont need to copy them to the lib.

    I suspect the windows equivilant is a shortcut?


    This is not a Signature...
      no, in windows i believe you'd have to physically copy the module files to the lib folders, because many applications dont "follow" shortcuts like they would symlinks

      as for the original post, i believe theres not much difference putting it in /lib or /site/lib for a windows installation. it would be more relevant however (correct me if im wrong) in a multi-user environment like unix/linux.

      __________
      Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
      - Terry Pratchett