Programming in Perl

Homework 5

Due: Tuesday, April 8th, 11:59:59pm EDT

FAQ started.


You have decided that this campus simply doesn't have enough File Searching utilities. Phynd and ACM's Celery aren't good enough for you, so you're going to write another one. The first version of your Searching program won't have all of its features implemented, but it's a decent start.

Write a Perl CGI script that provides a field for entering the filename to search for. Provide a method of allowing the user which files to search for (text, video, audio, image, etc). The user should be able to select more than one type of file.

When the user hits submit, your script should search a subdirectory of your cgi-bin directory that contains all the available files. Any file of the proper type, that contains the search term anywhere in its filename, should be returned. If the search term is *, all files of the appropriate type(s) should be returned. When you have obtained the list of files, create a list of links to those files, so that the user can click the links to download the files. Your script must also search all subdirectories of your cgi-bin/search/ directory.

As an example, if the user selectes text and audio files, and enters a search term of foo, all of the following files should be returned:

foo.txt
foo.wav
foobar.mp3
perl/barfoobaz.txt
Note that it is not necessary to match a subdirectoy name to the search term. In other words, in the above query, if there was a subdirectory called foo, you do not need to return all text and audio files in the foo directory.

Following is a list of file types and their associated extentions:

text
.txt
audio
.wav, .mp3
video
.asf, .avi, .mpg
image
.bmp, .jpg, .gif
Note that these are the minimum file associations. You are free to add more file types or more associations to the current types.

Realistic considerations

For this assignment, it is not actually necessary to put any audio, video, or image files in your CS account. You can simply create text files with the different extentions, with the contents of each file saying "This is a <type> file named <filename>". Indeed, you should put at a minimum the following files into your directory structure for the TAs to grade:

~/public.html/cgi-bin/search/foo.txt
~/public.html/cgi-bin/search/bar.txt
~/public.html/cgi-bin/search/foobar.txt
~/public.html/cgi-bin/search/hello.avi
~/public.html/cgi-bin/search/hello.jpg
~/public.html/cgi-bin/search/foo.wav
~/public.html/cgi-bin/search/hello.mpg
~/public.html/cgi-bin/search/perl/hw1.txt
~/public.html/cgi-bin/search/perl/hw2.txt
~/public.html/cgi-bin/search/perl/image.gif
~/public.html/cgi-bin/search/OpSys/assign1.wav
~/public.html/cgi-bin/search/OpSys/assign2.mp3

Also keep in mind that in order for your script to work, the search directory and all subdirectories, as well as the files within them must all be world-readable.

Grading Criteria

Create form with all fields:10
Find all files of given type:15
Find filenames containing search term:10
Search multiple types at once:15
Search all subdirectories:15
Return a list of matching files:10
Create hyperlinks for matching files:5
Compilation:5
Error Checking & Reporting:5
Code Style:5
Output Style:5
5 Above & Beyond points are available

Please note: Your entire program must be contained within ONE CGI script. You may not have one program that generates the form, and another that generates the output. You may submit multiple files if you wish to create your own class, but the files must combine to make ONE single executable program. There will be a 30 point penalty for anyone who fails to uphold this requirement.

Submission Instructions

For this assignment, you may only use the CGI submission script. There will be an extra field for you to enter the URL of your running script. Note that if you choose to do this project on your own server, you must insure that your own server is up and running at all times between the submission deadline and when you receive your grade.

If you so choose, you may again create your own objects and submit multiple files. Again, these files must have either a .tar.gz or a .zip extension. Anything else is treated as a single plaintext file.

The homework must be submitted by Tuesday, April 8th, at 11:59:59pm EDT