Perl was developed by Larry Wall in 1987 as a general scripting language. Perl 5 comes with most Linux operating systems. We have not used Perl 6 in Bristol yet.


See and googling a specific query will often turn up a suitable solution.


A perl script should start with
Other versions of perl can be provided on request.


[pavo]rahm: perl -version

This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi


Does your program run?


You can write a program or perl script by putting '#!/usr/bin/perl' on the first line followed by commands in the Perl language.

Or you can use 'perl one liners', in the example below, column 2 (which is the the third column as Perl counts from 0) will be printed from the multicolum text file data.raw.

cat data.raw | perl -lane 'print $F[2]' 
in the example below, all occurances of 'fudge' will be replaced by 'nougat' in the file sweets.txt.
perl -wpi -e 's/fudge/nougat/' sweets.txt

Author and References

The author of Perl is Larry Wall, and the three classic references are:
  1. Learning Perl by Randal L. Schwartz, brian d foy and Tom Phoenix
  2. Programming Perl: Unmatched power for text processing and scripting by Tom Christiansen, brian d foy, Larry Wall and Jon Orwant.
  3. Perl Cookbook by Tom Christiansen and Nathan Torkington
Copies of these books should be in the PhD student room.

Related Software

CPAN allows you to your own versions of Perl modules similar to the pip command for Python. To install the Perl Module 'Astro::XSPEC::TableModel' then you would type 'cpan', and at the cpan prompt 'install Astro::XSPEC::TableModel' as below:
rahm[pavo]rahm: cpan
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v2.14)
Enter 'h' for help.

cpan[1]> install Astro::XSPEC::TableModel
CPAN: Storable loaded ok (v2.20)
Reading '/homeb/rahm/.cpan/Metadata'
  Database was generated on Mon, 12 Sep 2016 10:29:02 GMT
Astro::XSPEC::TableModel is up to date (0.01).

Rhys Morris
Last modified: Monday, 12 September 2016