Install and manage Perl modules in my home directory on Carbonate at IU

On 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; 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'
    
  7. When returned to the shell prompt, run the CPAN module; enter:
    perl -MCPAN -e shell
    
  8. Configure the CPAN module to install new modules in your home directory; 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!
    
  9. 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'
    
  10. At the next CPAN prompt, enter:
    exit
    
  11. 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.
  12. 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.

  13. 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 have a question about installing and managing Perl modules, or need help, contact the UITS Research Applications and Deep Learning team.

This is document baiu in the Knowledge Base.
Last modified on 2019-04-10 10:52:00.

Contact us

For help or to comment, email the UITS Support Center.