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.txtNote 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:
~/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.
| 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 |
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.
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