CSE 341 -- Programming Languages
Autumn 2001
|
Department of Computer Science and Engineering,
University of Washington
Steve Tanimoto (instructor)
|
Assignment
7
Version 1.0 of Dec. 3.
(Subject to
Change) |
Perl Poem
Due date and time: Wednesday, December 12
2001 (at the beginning of class).
Turn-in instructions:
hard copy plus online files.
|
Title: Perl Poem
Purposes:
To work with Perl and CGI programming, including the use of
HTML forms and Perl regular expressions.
Instructions:
Read Chapters 1 through 9 in Sebesta's
A Little Book on Perl.
Part A: HTML
Create a web page containing an HTML form where a web surfer
can enter her/his name and click on a button to submit it.
Part B: Perl
Write a Perl program that will be activated when the web
surfer submits her/his name via your form.
The program will produce a web page that contains a poem
based upon the information provided by the user.
Your program
should do the following.
Get the user's name.
(You may use full name in one text field,
in 3 text fields, or only first name in one text field.)
Process the user's name by making the output depend on it.
Use at least one regular expression when processing the
user's name.
Use either an array or a hash somewhere in the program in
some way that makes sense.
Define and call at least one function that takes at least
one argument and uses that argument.
Output a web page with HTML tags.
Make your web page containing the form and your Perl
script work on a server.
Suggestions...
-
Use the rand function to select words
from lists of words.
-
Perform a transformation of the name and plug that into
the poem.
-
Use the name initials to select some of the words of
the poem.
-
Play some text-art tricks with the name, or create
e.e. cummings style poetry.
-
Make your poems be personalized holiday greetings.
-
Have your poem include images to decorate the page.
-
Have a choice box for in the form with some of your
friends' names in it, and let them enter their names
by selecting from the list. Then generate something
depending on their choice.
- Be creative. A poem can be as simple as some
randomly chosen words, laid out sequentially on the page.
Or it could be a more traditional poem that tells a story.
If you use an existing poem from the literature, be sure
to give appropriate credit to the source and put a disclaimer
on the page that explains that you take credit for any
distortions to the poem caused by your experimental software!
You might find the example Perl script near the end of
the Monday (Dec. 3) lecture slides to be helpful in terms
of the HTML form, retrieving CGI parameters, and matching
substrings with regular expressions.
Individual Work: This assignment
should be performed individually (not in groups).