home -- outline -- lectures -- assignments -- discussion -- tips -- links --



Searching a Movie Database

One of the simplest uses of a form is to search a predefined database. For this assignment, you will write a CGI script that will accept the form and process it.

We've created a simple database of films, directors and the years in which these films were made. Your assignment is to write a Perl program that accepts the name of the director or the film or the year in which it was made from the following form and search the database.

The database is available as the file /sgihomes/pradyut/html/hw5/database The fields are separated by the pipe symbol (|) and have the following format.

Name of Director|Name of Film|Year Made
Here are a few lines of the file as an example :
Sergei Eisenstein|Ivan the Terrible, Part One|1945
Akira Kurosawa|No Regrets for My Youth|1946
Alfred Hitchcock|Rich and Strange|1932
Luis Bunuel|Land Without Bread|1932
Akira Kurosawa|Not Yet|1993
Luis Bunuel|Young One, The|
Alfred Hitchcock|Waltzes from Vienna|1933
Kathryn Bigelow|Set-Up, The|1993 
Akira Kurosawa|Yojimbo|
  1. Copy the HTML document from http://classes.cs.uchicago.edu/~pradyut/hw5/hw5.html to your assignment directory and change the ACTION portion of the form to use your CGI script.
  2. Write a CGI script (in Perl) to search for the information from the database and display it in a nice format (of your own choosing.) Make sure you name your CGI script as hw5.cgi and set the execute permissions on it correctly.
Some useful hints:
  • There is no need to copy the database to your directory. You can access the file as /sgihomes/pradyut/html/hw5/database
  • If the date field of a movie is empty, then your program must print out "Unknown" as the date of the movie.
  • Movies with names like The Young One are stored as Young One, The in the database.