Perl/Environment
We recommend using local::lib to create your own directory of Perl packages downloaded from CPAN. This will create an isolated collection of packages, that will not affect the system version of Perl. This allows users to quickly bootstrap a local Perl Module library.
Creating an Environment
- You will first need to download a copy of local::lib. This can be found by searching local::lib at http://search.cpan.org/
- Decompress and extract the package:
-bash-3.2$ gunzip local-lib-2.000019.tar.gz -bash-3.2$ tar xvf local-lib-2.000019.tar
- Configure and then install the environment:
-bash-3.2$ cd local-lib-2.000019 -bash-3.2$ perl Makefile.PL --bootstrap -bash-3.2$ make test && make install
- Add the newly created environment to your initialization scripts. After this step is complete, you will need to start a new shell.
echo 'eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)' >>~/.bashrc
Note: Depending on your current initialization script setup, you may need to add the line generated by the above command to your .bash_profile as well. (Or the tcsh equivalent)
Module Management
Installing Modules
Once your environment has been created and properly sourced, you can then install packages with cpan as your normally would:
-bash-3.2$ cpan -i Date::Tolkien::Shire;
Listing Installed Modules
The following command will list all the Perl Modules installed in the currently sourced environment:
-bash-3.2$ perldoc perllocal
Creating additional Environments
By default your environment will be created in the ~/perl5 directory. It is possible to create multiple environments by specifying a directory in when building the environment:
-bash-3.2$ cd local-lib-2.000019 -bash-3.2$ perl Makefile.PL --bootstrap=/Path/to/Second/Environment -bash-3.2$ make test && make install
It is important to keep in mind that you will need to adjust the line in your initialization scrips to reflect the location of the Environment you wish to use.