Cookies

We use cookies to ensure that we give you the best experience on our website. You can change your cookie settings at any time. Otherwise, we'll assume you're OK to continue.

Durham University

Advanced Research Computing

Perl

Hamilton supports using the Perl programming language and is available via the usual perl command.

Each user is able to install Perl modules accessible only to them. As people will need different modules and versions of those modules, this is a useful way of giving users the flexibility to install software without waiting for the Hamilton administrators to install it for you.

Prior to attempting to install any Perl modules, you will need to execute the following command exactly (copy and paste is sensible, rather than typing it out by hand) and then log out:

echo 'eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)' >>~/.bashrc

Login to Hamilton again. The cpan command can now be used to install Perl modules under the perl5 folder in your home directory, e.g. cpan install JSON, and usable in your Perl programs with the usual use statement.

Example Perl program, in file my_perl_program.pl:

#!/usr/bin/env perl
print("hello, world!\n");

Example job script my_perl_job.sh to run a Perl program using a single CPU core:

#!/bin/bash

# Request resources:
#SBATCH -c 1          # 1 CPU core
#SBATCH --mem=1G      # 1 GB RAM
#SBATCH -t 1:0:0  # 1 hour (hours:minutes:seconds)

# Run in the default queue
# (job will share node with other jobs)
#SBATCH -p shared

# Commands to be run:

./my_perl_program.pl

Submit it to the queue with the command: sbatch my_perl_job.sh