dcsimg
Click Here!
Click Here!

Perl Primer Six Assignment
A Possible Answer

     To save on space, I'll only print the answer on the thank-you page. First off, here's the HTML Code:

<SELECT NAME="shipping">
<OPTION SELECTED VALUE="normal"> Normal Shipping
<OPTION VALUE="twoday">Two Day Shipping
<OPTION VALUE="overnight">Overnight
<OPTION VALUE="cheapskate">Book Rate Shipping
</SELECT>

     Now, here's how I'd handle that in the PERL script. I've pulled the other newsletter branching code out so this will be easier to see. You'll notice I only have four choices because I set up my menu to only allow those four and to always force a choice. I also put a <P> in there to assure I jump down a line. My changes are in bold.


sub thank_you {

    print "Content-type: text/html\n\n";
    print "<HTML>\n";
    print "<HEAD>\n";
    print "<TITLE>Thank You!</TITLE>\n";
    print "</HEAD>\n";
    print "<BODY BGCOLOR=#FFFFCC TEXT=#000000>\n";
    print "<H1>Thank You!</H1>\n";
    print "\n";
    print "<P>\n";
    print "<H3>Your feedback is greatly appreciated.<BR>\n";

if($FORM{shipping} eq "normal")
{print "<P>That will be two dollars sir";}

elsif($FORM{shipping} eq "twoday")
{print "<P>Two days? No problem!";}

elsif($FORM{shipping} eq "overnight")
{print "<P>Cool! Big spender.";}

else($FORM{shipping} eq "cheapskate")
{print "<P>Book rate? You bum!";}

    print "<P>\n";
    print "</BODY>\n";
    print "</HTML>\n";
    exit(0);
}





Close this window to return to the Primer