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

4.2 Individual 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. Learning Perl by Schwartz, & Christansen. Up through chapter 5.
  2. Programming Perl by Wall, Christansen, & Schwartz. Pattern-Matching Operators page 69-76.
  3. Programming Perl by Wall, Christansen, & Schwartz. chomp & chop page 149-150.
  4. Programming Perl by Wall, Christansen, & Schwartz. split page 220.
  5. 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 Individual Task

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

For the both tables print out a sequence number, the real names, user names, and e-mail addresses of the members of your group. The class this semester seems to have the group ID of 101.

For extra credit, look in /etc/group for the same group number and include the users added to group in the group file as well.

Print out the names in alphabetic order by last name. Set up the names as a link to the individuals index.html. Set up the username as mailto links. for an e-mail address assume the e-mail address is on system "cgi".

If you get your mail someplace else, please put your forwarding address in the file .forward.

For the second table do the same for all other users with a user ID greater than or equal to 1000.

  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:1038:1038:Louis Taber,R5A,,:/home/ltaber:/usr/bin/tcsh
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
    1. Users real name, first name first
    2. Comma separated room number
    3. Comma separated phone numbers
  6. Path to initial home directory.
  7. Program to run.

4.2.3 Report

Place your report in the turn in box in the lab. It need the following:
Instructor: ltaber@pima.edu** My new Home on phRed** The Pima College Site** The Mad Dr. G.'s home page on phred.

Prev Up Next