#!/usr/bin/perl #************************************************************ #** Robert W. Arts ** #** Pikeville College ** #** 214 Sycamore Street** #** Pikeville, KY 41501** #** (606) 437-3417** #**Email: rarts@pc.edu** #************************************************************ # This Perl script is designed to accept a single input (text or numeric) # from a form, look for them in a database type flat file (comma delimited) , and # return a HTML page with the match (hopefully only one) in a table. # The script's design is to allow a student to input a designated code number # in order to retrieve their updated (defined by the instructor) course # grades. This script generates a HTML FORM, with itself as the "ACTION" # When this script is called it checks the STDIN for data it may # be passing to itself. If there is none, it generates the FORM # plus some help text on how to use it. If it does see search # keys in STDIN ($keys) it will again print the FORM, skip the # help text, open the data file, search for matches, and print # them as a HTML table. #****************************************************************** #******************** Subroutines ******************************** #****************************************************************** #****************************************************************** #**************** Get Passed data from form *********************** #****************************************************************** sub GET_STATE_INFO { read(STDIN, $save_string, $ENV{CONTENT_LENGTH}); # Yes- Use it @prompts = split(/&/,$save_string); foreach (@prompts) { ($tmp1, $tmp2) = split(/=/,$_); $tmp2 =~ s/\x2b/\x20/g; $tmp2 =~ s/%2C/\x2c/g; $tmp2 =~ s/%28/\x28/g; $tmp2 =~ s/%29/\x29/g; $tmp2 =~ s/%30/\x30/g; $tmp2 =~ s/%31/\x31/g; $tmp2 =~ s/%32/\x32/g; $tmp2 =~ s/%33/\x33/g; $tmp2 =~ s/%34/\x34/g; $tmp2 =~ s/%35/\x35/g; $tmp2 =~ s/%36/\x36/g; $tmp2 =~ s/%37/\x37/g; $tmp2 =~ s/%38/\x38/g; $fields{$tmp1}=$tmp2; } $keys = $fields{'keys'}; $search_type = $fields{'search_type'}; } #****************************************************************** #********** Search file for lines with all search keys ************ #****************************************************************** sub SEARCH_FOR_MATCH { @search_key = split(/\x20/,$keys); open(MYFILE,"106AGRD.txt") || print "
Enter your personal code number in the box below. \n"; print "
\n"; if ( $keys eq "") { print ""; } else { print "| Code # | \n"; print "Lab 1 % | \n"; print "Lab 2 % | \n"; print "Lab 3 % | \n"; print "Lab 4 % | \n"; print "Lab 5 % | \n"; print "Lab 6 % | \n"; print "Lab 7 % | \n"; print "Lab 8 % | \n"; print "Lab 9 % | \n"; print "Lab 10 % | \n"; print "Lab 11 % | \n"; print "Total % |
|---|
| Limit of one match exceeded. Please contact instructor. | \n"; print "