Difference between revisions of "Perl"
(One intermediate revision by the same user not shown) | |||
Line 34: | Line 34: | ||
===CPAN Module Configuration=== | ===CPAN Module Configuration=== | ||
− | Execute the following command to start a CPAN shell: | + | #Execute the following command to start a CPAN shell: |
− | + | #*<pre>$ perl -MCPAN -e shell</pre> | |
− | <pre> | + | #The first time you run this, an interactive question and answer session will be started as CPAN configures itself. You can take all the defaults until it asks whether you want any parameters for perl Makefile.PL: |
− | $ perl -MCPAN -e shell | + | #*<pre>Every Makefile.PL is run by perl in a separate process.</pre> |
− | </pre> | + | #*<pre>...</pre> |
− | + | #*<pre>Your choice: []</pre> | |
− | The first time you run this, an interactive question and answer session will be started as CPAN configures itself. You can take all the defaults until it asks whether you want any parameters for perl Makefile.PL: | + | #You should answer with the following long line: |
− | + | #*<pre>PREFIX=~/perl5lib/ LIB=~/perl5lib/lib INSTALLMAN1DIR=~/perl5lib/man1 INSTALLMAN3DIR=~/perl5lib/man3</pre> | |
− | <pre> | + | #You can take defaults again until it comes time to choose mirrors of www.cpan.org from which you can install from. Choose as many as you like; I chose: |
− | Every Makefile.PL is run by perl in a separate process. | + | #*<pre>ftp://mirrors.kernel.org/pub/CPAN/</pre> |
− | ... | + | #*<pre>http://www.perl.com/CPAN/</pre> |
− | Your choice: [] | + | #After choosing your mirrors, press enter until you get the <code>cpan></code> prompt. Then quit (type '<code>q</code>'). |
− | </pre> | + | #Now tell perl to use your personal module repository by setting the <code>PERL5LIB</code> environment variable. For Bourne shell users, you would do this: |
− | + | #*<pre>$ PERL5LIB=~/perl5lib/lib</pre> | |
− | You should answer with the following long line: | + | #*<pre>$ export PERL5LIB</pre> |
− | + | #You should also add the above two lines to your <code>~/.bash_profile</code> so the <code>PERL5LIB</code> variable will be automatically set when you next log in. | |
− | <pre> | + | #Then start up CPAN again: |
− | PREFIX=~/perl5lib/ LIB=~/perl5lib/lib INSTALLMAN1DIR=~/perl5lib/man1 INSTALLMAN3DIR=~/perl5lib/man3 | + | #*<pre>$ perl -MCPAN -e shell</pre> |
− | </pre> | + | #You will be immediately greeted with the <code>cpan></code> prompt. At the <code>cpan></code> prompt, enter the following to get CPAN to update itself: |
− | + | #*<pre>install Bundle::CPAN</pre> | |
− | You can take defaults again until it comes time to choose mirrors of www.cpan.org from which you can install from. Choose as many as you like; I chose: | + | #*<pre>reload cpan</pre> |
− | |||
− | <pre> | ||
− | ftp://mirrors.kernel.org/pub/CPAN/ | ||
− | http://www.perl.com/CPAN/ | ||
− | </pre> | ||
− | |||
− | After choosing your mirrors, press enter until you get the <code>cpan></code> prompt. Then quit (type '<code>q</code>'). | ||
− | |||
− | Now tell perl to use your personal module repository by setting the <code>PERL5LIB</code> environment variable. For Bourne shell users, you would do this: | ||
− | |||
− | <pre> | ||
− | $ PERL5LIB=~/perl5lib/lib | ||
− | $ export PERL5LIB | ||
− | </pre> | ||
− | |||
− | You should also add the above two lines to your <code>~/.bash_profile</code> so the <code>PERL5LIB</code> variable will be automatically set when you next log in. | ||
− | |||
− | Then start up CPAN again: | ||
− | |||
− | <pre> | ||
− | $ perl -MCPAN -e shell | ||
− | </pre> | ||
− | |||
− | You will be immediately greeted with the <code>cpan></code> prompt. At the <code>cpan></code> prompt, enter the following to get CPAN to update itself: | ||
− | |||
− | <pre> | ||
− | install Bundle::CPAN | ||
− | reload cpan | ||
− | </pre> | ||
− | |||
and that's it! | and that's it! | ||
Line 90: | Line 60: | ||
Now that you have CPAN configured, you can install all the modules you want either from CPAN's interactive shell (<code>perl -MCPAN -e shell</code>) or from the command line (<code>perl -MCPAN -e 'install FOO::BAR'</code>). The modules will be installed into your <code>~/perl5lib/lib</code> directory. | Now that you have CPAN configured, you can install all the modules you want either from CPAN's interactive shell (<code>perl -MCPAN -e shell</code>) or from the command line (<code>perl -MCPAN -e 'install FOO::BAR'</code>). The modules will be installed into your <code>~/perl5lib/lib</code> directory. | ||
− | + | <div class="mw-collapsible mw-collapsed" style="width:70%; padding: 5px; border: 1px solid gray;"> | |
+ | ''Expand this section to view example of module installation.'' | ||
+ | <div class="mw-collapsible-content" style="padding: 5px;"> | ||
As a full example, we'll install the <code>File::Slurp</code> module into the username <code>user</code>'s <code>~/perl5lib</code> directory. | As a full example, we'll install the <code>File::Slurp</code> module into the username <code>user</code>'s <code>~/perl5lib</code> directory. | ||
Line 115: | Line 87: | ||
If all went well, the above command will return with no errors. | If all went well, the above command will return with no errors. | ||
− | + | </div></div>|}} | |
− | |||
− | |}} | ||
{{#if: {{#var: conf}}|==Configuration== | {{#if: {{#var: conf}}|==Configuration== | ||
See the [[{{PAGENAME}}_Configuration]] page for {{#var: app}} configuration details.|}} | See the [[{{PAGENAME}}_Configuration]] page for {{#var: app}} configuration details.|}} |
Latest revision as of 17:56, 2 January 2023
Description
Perl 5 is a highly capable, feature-rich programming language with over 23 years of development.
Environment Modules
Run module spider perl
to find out what environment modules are available for this application.
System Variables
- HPC_PERL_DIR - installation directory
- PERL5LIB - perl module path
Additional Information
Though modern-day Linux and Unix systems may have many perl modules already installed, the time may come when you use a module that was not shipped with your system or installed by your administrator. Don't fret - you can do this all by yourself by using the CPAN module. This document will describe how to use the CPAN module to install perl modules into a subdirectory of your home area which we'll call perl5lib
.
Note: If you are using the perl module by running module load perl you can request installation of additional modules by filing a support request.
CPAN Module Configuration
- Execute the following command to start a CPAN shell:
$ perl -MCPAN -e shell
- The first time you run this, an interactive question and answer session will be started as CPAN configures itself. You can take all the defaults until it asks whether you want any parameters for perl Makefile.PL:
Every Makefile.PL is run by perl in a separate process.
...
Your choice: []
- You should answer with the following long line:
PREFIX=~/perl5lib/ LIB=~/perl5lib/lib INSTALLMAN1DIR=~/perl5lib/man1 INSTALLMAN3DIR=~/perl5lib/man3
- You can take defaults again until it comes time to choose mirrors of www.cpan.org from which you can install from. Choose as many as you like; I chose:
ftp://mirrors.kernel.org/pub/CPAN/
http://www.perl.com/CPAN/
- After choosing your mirrors, press enter until you get the
cpan>
prompt. Then quit (type 'q
'). - Now tell perl to use your personal module repository by setting the
PERL5LIB
environment variable. For Bourne shell users, you would do this:$ PERL5LIB=~/perl5lib/lib
$ export PERL5LIB
- You should also add the above two lines to your
~/.bash_profile
so thePERL5LIB
variable will be automatically set when you next log in. - Then start up CPAN again:
$ perl -MCPAN -e shell
- You will be immediately greeted with the
cpan>
prompt. At thecpan>
prompt, enter the following to get CPAN to update itself:install Bundle::CPAN
reload cpan
and that's it!
Installing Additional Modules
Now that you have CPAN configured, you can install all the modules you want either from CPAN's interactive shell (perl -MCPAN -e shell
) or from the command line (perl -MCPAN -e 'install FOO::BAR'
). The modules will be installed into your ~/perl5lib/lib
directory.
Expand this section to view example of module installation.
As a full example, we'll install the File::Slurp
module into the username user
's ~/perl5lib
directory.
[user@submit2 ~]$ perl -MCPAN -e shell cpan shell -- CPAN exploration and modules installation (v1.7602) ReadLine support enabled cpan> install File::Slurp CPAN: Storable loaded ok ... ... ... /usr/bin/make install -j2 -- OK cpan>
With installation finished, we can test it interactively:
[user@submit2 ~]$ perl -e 'use File::Slurp;'
If all went well, the above command will return with no errors.