use CGI qw(:standard); print header; local $/ = "~\n"; $infile = param('file'); print start_html ( -title=>'quiz', -BGCOLOR=>'beige' ); print start_form ( -method=>'POST', -action=>"http://netlab/perl/obenberger/gradequiz.cgi" ); open (FILE, $infile) || die "Cannot open $infile: $!"; while () { chomp; ($type, $value) = split (/:/, $_); if ($type =~ m/q/i) { # ******* CHECKS FOR QUESTION LINE print "$value
"; } if ($type =~ m/a/i) { # ********* CHECKS FOR ANSWER LINE @answers = split (/,/, $value); $anslength = @answers; } if ($type =~ m/^s/) { # *** DETERMINES TYPE OF ANSWER BOX %selections = split (/,/, $value); @options = keys (%selections); if ($anslength > 1) { print checkbox_group(-name=>$type, -values=>\@options, -linebreak=>'true', -labels=>\%selections); }else { print "
"; print radio_group(-name=>$type, -values=>\@options, -linebreak=>'true', -labels=>\%selections, -default=>'-'); } print "


"; } } # ********** END WHILE STATEMENT close (FILE); print "
"; print submit (-value=>'Grade') . "   "; print reset (-value=>'Reset answers'); print "
"; print end_form; print end_html; #### use CGI qw(:standard); print header; print start_html (-title=>'graded quiz', -BGCOLOR=>'beige'); # The match doesn't work if more than one character is matched if(param('s1') =~ m/ad/i) { print "
Correct! Congradulations! Your answer was a

"; }else{ print "
Incorrect! You did not mark the correct answer!

"; } print "
The value for s1 is: "; print param('s1'); print "

"; print "The value for s2 is: "; print param('s2'); print "

"; print "The value for s3 is: "; print param('s3'); print "

"; print "The value for s4 is: "; print param('s4'); print "

"; print "


"; foreach $key (param()) { print "NAME = "; print $key; print " and VALUE = "; print param($key); print "

"; } print "


"; # Only the first character of the value is printed. Why? foreach $key (param()) { print "NAME = " . $key . "and VALUE = " . param($key) . "

"; } print end_html;