System Administration for the Web:
Week 7 Lab

October 24, 2005

1 Notes

This laboratory focuses entirely upon programming in Perl. We understand that many of you have had no programming experience at all, so we've tried to make this laboratory as simple as possible. However, don't feel too bad if you don't completely understand what you're doing - we aren't expecting you to learn how to program in just 40 minutes. You should be able to complete these exercises, though. We're planning on making one part of the project a programming exercise, so it's in your best interests to at least attempt to complete this assignment and ask questions if you run into trouble.

2 Running Perl Programs

To a computer, Perl programs are just ordinary text files. They only know to run a Perl program if you give your Perl program the appropriate permissions. In this case, the minimum permissions are read and execute.

If you've correctly specified the shebang line and set the correct permissions, executing your Perl program is as simple as typing something like the following:

./my_perl_program
in the directory that contains your Perl program. In the off-chance that you've accidentally created an infinite loop in your program, please recall that you can press Ctrl-C to terminate the execution of a program.

3 Lab for Week 7

3.1 Modifying A Simple Perl Program

The first half of this laboratory will be modifying the guessing number game presented during lecture and in the lecture notes. I've conveniently placed a copy of this program in the /home/cc/cs198/fa05/class/cs198-ec/labs/lab7 directory.

[1]
Copy the guess_the_number.pl file to your home directory.
[2]
Modify the program to ask the user for the maximum random number.
[3]
Modify the program to count the number of guesses a person uses and to print this number when the user guesses the correct number.

3.2 Writing Your Own Programs

[1]
Write a program that prompts the user for and reads two numbers (on separate lines of input) and prints out the product of the two numbers multiplied together.
[2]
Write a program that will ask the user for a given name and report the corresponding family name. Use a hash of given and family names in your program.

About this document ...

System Administration for the Web:
Week 7 Lab

This document was generated using the LaTeX2HTML translator Version 2002-2-1 (1.71)

Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.

The command line arguments were:
latex2html -split 0 -show_section_numbers -no_navigation decal_lab_week7.tex

The translation was initiated by zeroion on 2005-10-24


zeroion 2005-10-24