Hi all.
This is a homework project. I have already finished it but I was wondering if any of you had an opinion regarding where I could improve something? The amount of work I have put into this is trvial by programming standards. Never-the-less, I intensely dislike submitting assignments I know could have been improved upon.
Thanks in advance,
-Katie.
#!/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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|