
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.
Preparation for this section requires you do some Perl programming.
This programming needs to include the following:
- Open and closing files.
- Reading the content of a file and finding the end-of-file.
- Using arrays.
- Using associative arrays.
- Manipulate numeric and string values.
Please read the following:
- Programming Perl by Wall, Christansen, & Schwartz.
Pattern-Matching Operators
page 69-76.
- Programming Perl by Wall, Christansen, & Schwartz.
chomp
& chop
page 149-150.
- Programming Perl by Wall, Christansen, & Schwartz.
split
page 220.
- 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
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.
- Test your program on the command line without a web browser.
- Move your program and data to the
cgi-bin
, set the correct
permissions on your files, and execute it from a web browser.
- 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:
- User name
- Place holder for password.
- UID (User IDentification number)
- GID (Group IDentification number)
- User information in three sub-fields
- Users real name, first name first
- In our case - the group
- In our case - the e-mail address
- Path to initial home directory.
- Program to run.
e-mail your group's report (only one copy please) as follows:
- To: ltaber@pima.edu
- Subject: CSC266 Topic: 4.2: Perl 1
- Attach:
- Your groups Perl file.
- Message text:
- URL of the groups program.
- Suggestions on topic.
Please hand-in a printout of your page.
Instructor: ltaber@pima.edu** Red's Home page** The Pima College Site
