ARCHIVED: Install and manage Perl modules in your home directory on Carbonate

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

On ARCHIVED: Carbonate at Indiana University, use the local::lib module and CPAN to install and manage your own library of Perl modules:

  1. Make a personal configuration for use with the CPAN module:
    1. On the command line, enter:
      perl -MCPAN -e 'mkmyconfig'
    2. When prompted, press Enter or Return to allow automatic configuration.
    3. For "What approach do you want?", press Enter or Return to select the default option (local::lib).
    4. Press Enter or Return to let the application automatically choose CPAN mirror sites.
    5. Press Enter or Return to add the necessary environment variables to your shell configuration file.
    6. If prompted to run automatic configuration again, press Enter or Return to select [yes].

      You'll see output indicating autoconfiguration is complete, with MyConfig.pm written to the following directory (replace username with your IU username):

      /N/u/username/Carbonate/.cpan/CPAN/MyConfig.pm'
  2. When returned to the shell prompt, run the CPAN module; enter:
    perl -MCPAN -e shell
  3. Configure the CPAN module to install new modules in your home directory:
    1. At the first CPAN prompt (cpan[1]>), enter:
      o conf makepl_arg INSTALL_BASE=~/perl5

      You'll see the following output:

      makepl_arg         [INSTALL_BASE=~/perl5]
      Please use 'o conf commit' to make the config permanent!
    2. At the next CPAN prompt, enter:
      o conf commit

      You'll see the following output (replace username with your IU username):

      commit: wrote '/N/u/username/Carbonate/.cpan/CPAN/MyConfig.pm'
    3. At the next CPAN prompt, enter:
      exit
  4. Modify your environment to use the new library of modules:
    • If you're using the bash shell, add the following lines to your ~/.bashrc file (replace username with your IU username):
      export PERL_MM_OPT="INSTALL_BASE=/N/u/username/Carbonate/perl5"
      export PERL5LIB="/N/u/username/Carbonate/perl5/lib/perl5:$PERL5LIB"
      export PATH="/N/u/username/Carbonate/perl5/bin:$PATH"
      eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)
    • If you're using a variant of the C shell, you'll need to set the environment variables manually in your shell configuration file.
  5. Use the CPAN module (or the cpan command) to install modules locally:
    $ perl -MCPAN -Mlocal::lib -e 'CPAN::install(Math::Matrix)'

    This will produce a lot of output.

  6. In your Perl script, use the local::lib module to have your local library searched when modules are loaded:
    #!/usr/bin/perl
    use strict;
    use local::lib;
    use Math::Matrix;

If you need help installing and managing Perl modules on Carbonate, contact the UITS Research Applications and Deep Learning team.

This is document baiu in the Knowledge Base.
Last modified on 2023-12-17 07:02:35.