Laboratory Exercises for Introduction to Perl

Homework: Get Acquainted With Unix

If you are a newcomer to Unix or would like a refresher, please do the following assignment outside of class:

This will review some basic commands, like changing directories, editing files, running programs, etc.. Once you are familiar with this material, you should be prepared to do the laborary exercises.

Setup Initial Directory

Before doing the exercises, you will need to create a copy of the programs and data files in a directory in your account on ada. (See alternate instructions if you are not using one of our computers.)

  1. Login to ada.
  2. Enter the following command on ada:

  3. You will be prompted to select a directory name which will be created, into which the files will be copied. The default is /scratch/user/USER/PerlLab/, and you can just hit the Enter key to accept that.
  4. Change to the new directory. If you used the default:

    cd /scratch/USER/PerlLab

  5. List the contents to make sure your setup is correct:


    You should see:

    Lab1 Lab2 Lab3 ... README Slides

    The Slides directory contains material from the presentation slides. The Labi directories contains the material for these exercises.
  6. Proceed to exercises.

Alternate instructions

Skip this section if you are using ada and have completed the preceding section.

  1. Login to your computer.
  2. Make sure you have perl available. Installation instructions are at
  3. Download the exercises (Windows - zip format) (Linux/OS X - tar.gz format)
  4. Extract the files into your chosen directory (known as a "folder" on some operating systems).
  5. Open a terminal or other command-line interface.
  6. Proceed to exercises in next section.


The following exercises should help to get you familiar with different aspects of programming Perl. There are questions, hints, and solutions available interactively, so you can go at your own pace. Feel free to skip exercises which you don't think are relevant to your work. You can always go back and do them later.

  1. Executing sample Perl scripts
  2. Conditionals and loops
  3. Reading and writing files
  4. Searching for pattern matches
  5. Processing input