Prev Up Next
Go backward to 4.1 CGI Introduction Topic
Go up to 4 Major Topics
Go forward to 4.3 CGI Server Side Include Topic

4.2 CGI Introduction to Perl Topic

The purpose of this section is to introduce Perl programming. It won't teach you programming, and it won't even teach you all of Perl. But it should get you started writing Perl programs that can do something useful.

4.2.1 Preparation

Preparation for this section requires you do some Perl programming. This programming needs to include the following:
  1. Open and closing files.
  2. Reading the content of a file and finding the end-of-file.
  3. Using arrays.
  4. Using associative arrays.
  5. Manipulate numeric and string values.
Please read the following:
  1. Programming Perl by Wall, Christansen, & Schwartz. Pattern-Matching Operators page 69-76.
  2. Programming Perl by Wall, Christansen, & Schwartz. chomp & chop page 149-150.
  3. Programming Perl by Wall, Christansen, & Schwartz. split page 220.
  4. About tables in HTML
Write a little "test" program for each programming construct above. You are also welcome to tie them into a single program

4.2.2 Group Task

You will need to write a program that reads the file /etc/passwd and creates a table for your group and another table for the entire class. The program will need to write HTML with a title, header, and tables.

The password file has a number of unrelated entries. In the name field, for this class, the second sub-field has a single letter that indicates the group that the individual student is in. Only use entries that have a single upper case letter in this sub-field.

For the first and group table print out a sequence number, the real names, user names, and e-mail addresses of the members of your group. Set up the names as a link to the individuals index.html. Set up the e-mail addresses as mailto links. If there is no entry in the third sub-field for an e-mail address assume the e-mail address is on system "cgi". Sort the table by username (or by last name for extra credit).

For the second table do the same for the entire class.

  1. Test your program on the command line without a web browser.
  2. Move your program and data to the cgi-bin, set the correct permissions on your files, and execute it from a web browser.
  3. Modify your index.html so that it points to your program.
For your information the format of the password file looks like this:
ltaber:x:1000:1000:
       Louis Taber,I,ltaber@red.cscwc.pima.edu:
                           /home/ltaber:/usr/bin/tcsh
A single entry was broken into three lines so that it could print. Look at the file for the actual format. The fields are:
  1. User name
  2. Place holder for password.
  3. UID (User IDentification number)
  4. GID (Group IDentification number)
  5. User information in three sub-fields
    1. Users real name, first name first
    2. In our case - the group
    3. In our case - the e-mail address
  6. Path to initial home directory.
  7. Program to run.

4.2.3 Report

e-mail your group's report (only one copy please) as follows: Please hand-in a printout of your page.
Instructor: ltaber@pima.edu** Red's Home page** The Pima College Site

Prev Up Next