Difference between revisions of "Perl"

From UFRC
Jump to navigation Jump to search
Line 5: Line 5:
 
|{{#vardefine:app|perl}}
 
|{{#vardefine:app|perl}}
 
|{{#vardefine:url|http://www.perl.org/}}
 
|{{#vardefine:url|http://www.perl.org/}}
|{{#vardefine:exe|}} <!--Present manual instructions for running the software -->
+
|{{#vardefine:exe|1}} <!--Present manual instructions for running the software -->
 
|{{#vardefine:conf|}} <!--Enable config wiki page link - {{#vardefine:conf|1}} = ON/conf|}} = OFF-->
 
|{{#vardefine:conf|}} <!--Enable config wiki page link - {{#vardefine:conf|1}} = ON/conf|}} = OFF-->
 
|{{#vardefine:pbs|}} <!--Enable PBS script wiki page link-->
 
|{{#vardefine:pbs|}} <!--Enable PBS script wiki page link-->
Line 27: Line 27:
 
<!--Additional-->
 
<!--Additional-->
 
{{#if: {{#var: exe}}|==Additional Information==
 
{{#if: {{#var: exe}}|==Additional Information==
WRITE INSTRUCTIONS ON RUNNING THE ACTUAL BINARY|}}
+
 
 +
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 <code>perl5lib</code>.
 +
 
 +
'''Note: If you are using the ''perl'' module by running ''module load perl'' you can request installation of additional modules by filing a [http://support.rc.ufl.edu support request].'''
 +
 
 +
==CPAN Module Configuration==
 +
 
 +
Execute the following command to start a CPAN shell:
 +
 
 +
<pre>
 +
$ perl -MCPAN -e shell
 +
</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:
 +
 
 +
<pre>
 +
Every Makefile.PL is run by perl in a separate process. Likewise we
 +
run 'make' and 'make install' in processes. If you have any
 +
parameters (e.g. PREFIX, LIB, UNINST or the like) you want to pass
 +
to the calls, please specify them here.
 +
 +
If you don't understand this question, just press ENTER.
 +
 +
Parameters for the 'perl Makefile.PL' command?
 +
Typical frequently used settings:
 +
 +
    POLLUTE=1        increasing backwards compatibility
 +
    LIB=~/perl      non-root users (please see manual for more hints)
 +
 +
Your choice:  []
 +
</pre>
 +
 
 +
You should answer with the following long line:
 +
 
 +
<pre>
 +
PREFIX=~/perl5lib/ LIB=~/perl5lib/lib INSTALLMAN1DIR=~/perl5lib/man1 INSTALLMAN3DIR=~/perl5lib/man3
 +
</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>
 +
ftp://mirrors.kernel.org/pub/CPAN/
 +
ftp://mirrors1.kernel.org/pub/CPAN/
 +
ftp://mirrors2.kernel.org/pub/CPAN/
 +
ftp://mirror.sit.wisc.edu/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!
 +
 
 +
==Installing Additional Modules==
 +
 
 +
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.
 +
 
 +
As a full example, we'll install the <code>File::Slurp</code> module into the username <code>user</code>'s <code>~/perl5lib</code> directory.
 +
 
 +
<pre>
 +
[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>
 +
</pre>
 +
 
 +
With installation finished, we can test it interactively:
 +
 
 +
<pre>
 +
[user@submit2 ~]$ perl -e 'use File::Slurp;'
 +
</pre>
 +
 
 +
If all went well, the above command will return with no errors.
 +
 
 +
 
 +
|}}
 
{{#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.|}}

Revision as of 19:10, 24 October 2022

Description

perl website  

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. Likewise we
run 'make' and 'make install' in processes. If you have any
parameters (e.g. PREFIX, LIB, UNINST or the like) you want to pass
to the calls, please specify them here.
 
If you don't understand this question, just press ENTER.
 
Parameters for the 'perl Makefile.PL' command?
Typical frequently used settings:
 
    POLLUTE=1        increasing backwards compatibility
    LIB=~/perl       non-root users (please see manual for more hints)
 
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/
ftp://mirrors1.kernel.org/pub/CPAN/
ftp://mirrors2.kernel.org/pub/CPAN/
ftp://mirror.sit.wisc.edu/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 the PERL5LIB 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 the cpan> 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.

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.