#!/usr/bin/perl -wT use strict; use CGI qw( :standard ); use CGI::Carp qw( fatalsToBrowser ); print "Content-type: text/html\n\n"; my ( $question_one, $question_two, $question_three, $question_four, $question_five, $question_six, $question_seven, $question_eight, $question_nine, $question_ten ); my $total = 10; my $score; my $final_score; $question_one = param( "Q1" ); $question_two = param( "Q2" ); $question_three = param( "Q3" ); $question_four = param( "Q4" ); $question_five = param( "Q5" ); $question_six = param( "Q6" ); $question_seven = param( "Q7" ); $question_eight = param( "Q8" ); $question_nine = param( "Q9" ); $question_ten = param( "Q10" ); if( $question_one eq "Larry Wall" ) { print "1). You answered: $question_one <FONT COLOR=\"Green\">Correct +!</FONT><BR>"; $score++; } else { print "1). You answered: $question_one <FONT COLOR=\"RED\">Incorrect +</FONT><BR>"; } if( $question_two eq "Unix administrators" ) { print "2). You answered: $question_two <FONT COLOR=\"Green\">Correct +!</FONT><BR>"; $score++; } else { print "2). You answered: $question_two <FONT COLOR=\"RED\">Incorrect +</FONT><BR>"; } if( $question_three eq "Text processing" ) { print "3). You answered: $question_three <FONT COLOR=\"Green\">Corre +ct!</FONT><BR>"; $score++; } else { print "3). You answered: $question_three <FONT COLOR=\"RED\">Incorre +ct</FONT><BR>"; } if( $question_four eq "Glue" ) { print "4). You answered: $question_four <FONT COLOR=\"Green\">Correc +t!</FONT><BR>"; $score++; } else { print "4). You answered: $question_four <FONT COLOR=\"RED\">Incorrec +t</FONT><BR>"; } if( $question_five eq "Operating system utilities and services" ) { print "5). You answered: $question_five <FONT COLOR=\"Green\">Correc +t!</FONT><BR>"; $score++; } else { print "5). You answered: $question_five <FONT COLOR=\"RED\">Incorrec +t</FONT><BR>"; } if( $question_six eq "True" ) { print "6). You answered: $question_six <FONT COLOR=\"Green\">Correct +!</FONT><BR>"; $score++; } else { print "6). You answered: $question_six <FONT COLOR=\"RED\">Incorrect +</FONT><BR>"; } if( $question_seven eq "Regular expressions" ) { print "7). You answered: $question_seven <FONT COLOR=\"Green\">Corre +ct!</FONT><BR>"; $score++; } else { print "7). You answered: $question_seven <FONT COLOR=\"RED\">Incorre +ct</FONT><BR>"; } if( $question_eight eq "Open source" ) { print "8). You answered: $question_eight <FONT COLOR=\"Green\">Corre +ct!</FONT><BR>"; $score++; } else { print "8). You answered: $question_eight <FONT COLOR=\"RED\">Incorre +ct</FONT><BR>"; } if( $question_nine eq "TCL" ) { print "9). You answered: $question_nine <FONT COLOR=\"Green\">Correc +t!</FONT><BR>"; $score++; } else { print "9). You answered: $question_nine <FONT COLOR=\"RED\">Incorrec +t</FONT><BR>"; } if( $question_ten eq "Marc Andreessen" ) { print "10). You answered: $question_ten <FONT COLOR=\"Green\">Correc +t!</FONT><BR>"; $score++; } else { print "10). You answered: $question_ten <FONT COLOR=\"RED\">Incorrec +t</FONT><BR>"; } $final_score = ( $score * 10 ); print <<EOF; <TABLE> <TR><TD>Total questions: $total</TD><TD>Total answered correctly: $sco +re</TD><TD>Your final score: $final_score\%</TD></TR> </TABLE> EOF
edited: Sun Mar 9 15:00:05 2003 by jeffa - added readmore tags
In reply to Writing a perl quiz. Need advice. by DigitalKitty
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |