Graham Kemp > Programming Tools


Practical: Perl 1

Aims

Objectives

After this practical you will:

Exercises

  1. Try out some of the scripts from the lecture. Some of these are in directory /users/mdstud/kemp/ptools/perl/lecture1/.

  2. Copy the program countdown.pl and modify it so that it counts down from a number entered by the user in response to a prompt, e.g.

    unix> ./countdown2.pl
    Type in a number: 3
    3...
    2...
    1...
    BOOM!
    unix>
    
  3. Copy your solution for Question 2 and modify it so that it uses a "for" loop instead of a "while" loop.

  4. Copy your solution for Question 3 and modify it so that it counts down from a number given as a command line argument.

    unix> ./countdown4.pl 3
    3...
    2...
    1...
    BOOM!
    unix>
    
  5. File /users/mdstud/kemp/ptools/unix3/names contains the names of some of the students taking this course. Write a Perl program that reads this file and writes out an HTML file with a table containing the students' names in the first column and their lab account usernames in the second column (like http://www.cs.chalmers.se/~kemp/teaching/programming_tools/2004/local/accounts.html but with the columns reversed).