Perl: Difference between revisions
(Created page with "{{Draft}} == Description == [http://www.perl.org Perl] is a free programming language which is interpreted and has acquired a vast library of contributed packages over the 25...") |
No edit summary |
||
(15 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<languages /> | |||
[[Category:Software]] | |||
== Description == | <translate> | ||
== Description == <!--T:1--> | |||
[http://www.perl.org Perl] is a free programming language which is interpreted and has acquired a vast library of contributed packages over the 25+ years of its existence. Its strengths are manipulating strings, database access and its portability ([http://www.cio.com/article/175450/You_Used_Perl_to_Write_WHAT_ according to this article]). Its weaknesses are its poor performance and the ease with which one can write obscure and illegible code. By design, Perl offers several different ways of accomplishing the same task. Many programmers have adopted this language and write code that is very compact but difficult to decipher. | [http://www.perl.org Perl] is a free programming language which is interpreted and has acquired a vast library of contributed packages over the 25+ years of its existence. Its strengths are manipulating strings, database access and its portability ([http://www.cio.com/article/175450/You_Used_Perl_to_Write_WHAT_ according to this article]). Its weaknesses are its poor performance and the ease with which one can write obscure and illegible code. By design, Perl offers several different ways of accomplishing the same task. Many programmers have adopted this language and write code that is very compact but difficult to decipher. | ||
== Loading the Interpreter == | == Loading the Interpreter == <!--T:2--> | ||
The Perl language is made available on Compute Canada's servers using a module which you can load like any other, e.g. | The Perl language is made available on Compute Canada's servers using a module which you can load like any other, e.g. | ||
{{Command|module | {{Command|module spider perl}} | ||
to see which versions are installed and then | to see which versions are installed and then | ||
{{Command|module load perl/5. | {{Command|module load perl/5.30.2}} | ||
to load a particular version. | to load a particular version. | ||
== Installing Packages == | == Installing Packages == <!--T:3--> | ||
A large number of Perl packages can be installed by means of the [http://www.cpan.org/ Comprehensive Perl Archive Network], by using the tool <tt>cpan</tt>, which however must first be initialized correctly in | A large number of Perl packages can be installed by means of the [http://www.cpan.org/ Comprehensive Perl Archive Network], by using the tool <tt>cpan</tt>, which however must first be initialized correctly in order to install them in your home directory. Note that many Perl packages are developed using the Gcc compiler family, so we recommend that you load a <tt>gcc</tt> module before attempting to install any Perl packages: | ||
order to install them in your home directory. | {{ | ||
Command | |||
|module load gcc/9.3.0 | |||
}} | |||
=== Initial Configuration for Package Installation === | === Initial Configuration for Package Installation === <!--T:4--> | ||
During the first execution of the command <tt>cpan</tt> the utility will ask you if you want to allow it to configure the majority of settings automatically. Respond <tt>yes</tt>. | During the first execution of the command <tt>cpan</tt> the utility will ask you if you want to allow it to configure the majority of settings automatically. Respond <tt>yes</tt>. | ||
{{ | {{ | ||
Line 24: | Line 28: | ||
... | ... | ||
<!--T:5--> | |||
Would you like me to configure as much as possible automatically? [yes] | Would you like me to configure as much as possible automatically? [yes] | ||
... | ... | ||
What approach do you want? (Choose 'local::lib', 'sudo' or 'manual') | |||
[local::lib] | |||
... | |||
<!--T:14--> | |||
</nowiki> | </nowiki> | ||
}} | }} | ||
The <tt>cpan</tt> utility will offer to append a variety of environment variable settings to your .bashrc file, which you should agree to. You can then type the command <tt>quit</tt> at the interface to exit the <tt>cpan</tt> software. Before installing any Perl modules you will need to restart your shell for these new settings to take effect. | |||
=== Package Installation === | === Package Installation === <!--T:6--> | ||
When the initial configuration is done, you can install any of the more than 25,000 packages available on CPAN. For example: | When the initial configuration is done, you can install any of the more than 25,000 packages available on CPAN. For example: | ||
{{ | {{ | ||
Line 46: | Line 47: | ||
|result= | |result= | ||
<nowiki> | <nowiki> | ||
Terminal does not support AddHistory. | |||
cpan> install | <!--T:15--> | ||
cpan shell -- CPAN exploration and modules installation (v2.11) | |||
Enter 'h' for help. | |||
</nowiki> | |||
cpan[1]> install Chess | |||
<nowiki> | |||
... | ... | ||
Running install for module | Running install for module 'Chess' | ||
Fetching with LWP: | Fetching with LWP: | ||
http://www.cpan.org/authors/id/B/BJ/BJR/Chess-0.6.2.tar.gz | |||
Fetching with LWP: | Fetching with LWP: | ||
http://www.cpan.org/authors/id/B/BJ/BJR/CHECKSUMS | |||
... | Checksum for /home/stubbsda/.cpan/sources/authors/id/B/BJ/BJR/Chess-0.6.2.tar.gz ok | ||
Scanning cache /home/stubbsda/.cpan/build for sizes | |||
............................................................................DONE | |||
'YAML' not installed, will not store persistent state | |||
Configuring B/BJ/BJR/Chess-0.6.2.tar.gz with Makefile.PL | |||
Checking if your kit is complete... | Checking if your kit is complete... | ||
Looks good | Looks good | ||
... | |||
Running make for B/BJ/BJR/Chess-0.6.2.tar.gz | |||
... | ... | ||
Running make test | Running make test | ||
PERL_DL_NONLAZY=1 / | PERL_DL_NONLAZY=1 "/cvmfs/soft.computecanada.ca/nix/store/g8ds64pbnavscf7n754pjlx5cp1mkkv1-perl-5.22.2/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t | ||
t/ | t/bishop.t ......... ok | ||
t/ | t/board.t .......... ok | ||
t/checkmate.t ...... ok | |||
t/game.t ........... ok | |||
t/king.t ........... ok | |||
t/knight.t ......... ok | |||
t/movelist.t ....... ok | |||
t/movelistentry.t .. ok | |||
t/pawn.t ........... ok | |||
t/piece.t .......... ok | |||
t/queen.t .......... ok | |||
t/rook.t ........... ok | |||
t/stalemate.t ...... ok | |||
All tests successful. | All tests successful. | ||
Files= | Files=13, Tests=311, 3 wallclock secs ( 0.14 usr 0.05 sys + 2.49 cusr 0.20 csys = 2.88 CPU) | ||
Result: PASS | |||
... | ... | ||
Installing /home/stubbsda/perl5/man/man3/Chess::Piece::Knight.3 | |||
Installing /home/stubbsda/perl5/man/man3/Chess.3 | |||
Installing /home/stubbsda/perl5/man/man3/Chess::Piece::Bishop.3 | |||
Installing /home/stubbsda/perl5/man/man3/Chess::Board.3 | |||
Appending installation info to /home/stubbsda/perl5/lib/perl5/x86_64-linux-thread-multi/perllocal.pod | |||
BJR/Chess-0.6.2.tar.gz | |||
/cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/bin/make install -- OK | |||
</nowiki> | |||
cpan[2]> | |||
<nowiki> | |||
</nowiki> | </nowiki> | ||
}} | }} | ||
</translate> | |||
Latest revision as of 18:03, 16 March 2021
Description
Perl is a free programming language which is interpreted and has acquired a vast library of contributed packages over the 25+ years of its existence. Its strengths are manipulating strings, database access and its portability (according to this article). Its weaknesses are its poor performance and the ease with which one can write obscure and illegible code. By design, Perl offers several different ways of accomplishing the same task. Many programmers have adopted this language and write code that is very compact but difficult to decipher.
Loading the Interpreter
The Perl language is made available on Compute Canada's servers using a module which you can load like any other, e.g.
[name@server ~]$ module spider perl
to see which versions are installed and then
[name@server ~]$ module load perl/5.30.2
to load a particular version.
Installing Packages
A large number of Perl packages can be installed by means of the Comprehensive Perl Archive Network, by using the tool cpan, which however must first be initialized correctly in order to install them in your home directory. Note that many Perl packages are developed using the Gcc compiler family, so we recommend that you load a gcc module before attempting to install any Perl packages:
[name@server ~]$ module load gcc/9.3.0
Initial Configuration for Package Installation
During the first execution of the command cpan the utility will ask you if you want to allow it to configure the majority of settings automatically. Respond yes.
[name@server ~]$ cpan
...
Would you like me to configure as much as possible automatically? [yes]
...
What approach do you want? (Choose 'local::lib', 'sudo' or 'manual')
[local::lib]
...
The cpan utility will offer to append a variety of environment variable settings to your .bashrc file, which you should agree to. You can then type the command quit at the interface to exit the cpan software. Before installing any Perl modules you will need to restart your shell for these new settings to take effect.
Package Installation
When the initial configuration is done, you can install any of the more than 25,000 packages available on CPAN. For example:
[name@server ~]$ cpan
Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v2.11)
Enter 'h' for help.
cpan[1]> install Chess
...
Running install for module 'Chess'
Fetching with LWP:
http://www.cpan.org/authors/id/B/BJ/BJR/Chess-0.6.2.tar.gz
Fetching with LWP:
http://www.cpan.org/authors/id/B/BJ/BJR/CHECKSUMS
Checksum for /home/stubbsda/.cpan/sources/authors/id/B/BJ/BJR/Chess-0.6.2.tar.gz ok
Scanning cache /home/stubbsda/.cpan/build for sizes
............................................................................DONE
'YAML' not installed, will not store persistent state
Configuring B/BJ/BJR/Chess-0.6.2.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
...
Running make for B/BJ/BJR/Chess-0.6.2.tar.gz
...
Running make test
PERL_DL_NONLAZY=1 "/cvmfs/soft.computecanada.ca/nix/store/g8ds64pbnavscf7n754pjlx5cp1mkkv1-perl-5.22.2/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/bishop.t ......... ok
t/board.t .......... ok
t/checkmate.t ...... ok
t/game.t ........... ok
t/king.t ........... ok
t/knight.t ......... ok
t/movelist.t ....... ok
t/movelistentry.t .. ok
t/pawn.t ........... ok
t/piece.t .......... ok
t/queen.t .......... ok
t/rook.t ........... ok
t/stalemate.t ...... ok
All tests successful.
Files=13, Tests=311, 3 wallclock secs ( 0.14 usr 0.05 sys + 2.49 cusr 0.20 csys = 2.88 CPU)
Result: PASS
...
Installing /home/stubbsda/perl5/man/man3/Chess::Piece::Knight.3
Installing /home/stubbsda/perl5/man/man3/Chess.3
Installing /home/stubbsda/perl5/man/man3/Chess::Piece::Bishop.3
Installing /home/stubbsda/perl5/man/man3/Chess::Board.3
Appending installation info to /home/stubbsda/perl5/lib/perl5/x86_64-linux-thread-multi/perllocal.pod
BJR/Chess-0.6.2.tar.gz
/cvmfs/soft.computecanada.ca/nix/var/nix/profiles/16.09/bin/make install -- OK
cpan[2]>