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


In reply to Writing a perl quiz. Need advice. by DigitalKitty

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.