Difference between revisions of "Perl/Environment"

From UMIACS
Jump to navigation Jump to search
(Created page with "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 th...")
 
 
(One intermediate revision by one other user not shown)
Line 6: Line 6:
  
 
*Decompress and extract the package:
 
*Decompress and extract the package:
<pre>-bash-3.2$ gunzip local-lib-2.000014.tar.gz
+
<pre>-bash-3.2$ gunzip local-lib-2.000019.tar.gz
-bash-3.2$ tar xvf local-lib-2.000014.tar
+
-bash-3.2$ tar xvf local-lib-2.000019.tar
 
</pre>
 
</pre>
  
 
*Configure and then install the environment:
 
*Configure and then install the environment:
<pre>-bash-3.2$ cd local-lib-2.000014
+
<pre>-bash-3.2$ cd local-lib-2.000019
 
-bash-3.2$ perl Makefile.PL --bootstrap
 
-bash-3.2$ perl Makefile.PL --bootstrap
 
-bash-3.2$ make test && make install
 
-bash-3.2$ make test && make install
Line 26: Line 26:
 
-bash-3.2$ cpan -i Date::Tolkien::Shire;
 
-bash-3.2$ cpan -i Date::Tolkien::Shire;
 
</pre>
 
</pre>
 +
For more information on module installation, see  http://www.cpan.org/modules/INSTALL.html
 +
 
===Listing Installed Modules===
 
===Listing Installed Modules===
 
The following command will list all the Perl Modules installed in the currently sourced environment:
 
The following command will list all the Perl Modules installed in the currently sourced environment:
Line 34: Line 36:
 
==Creating additional Environments==
 
==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:
 
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:
<pre>-bash-3.2$ cd local-lib-2.000014
+
<pre>-bash-3.2$ cd local-lib-2.000019
 
-bash-3.2$ perl Makefile.PL --bootstrap=/Path/to/Second/Environment
 
-bash-3.2$ perl Makefile.PL --bootstrap=/Path/to/Second/Environment
 
-bash-3.2$ make test && make install
 
-bash-3.2$ make test && make install

Latest revision as of 21:04, 13 July 2016

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;

For more information on module installation, see http://www.cpan.org/modules/INSTALL.html

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.