CECS 5100

Survey of Educational Computer Languages

Fall 2002

Need a free MP3 Player to listen to these clips ?

October 24th, 2002
  • Example of Final Projects
    Audio (2.4M 5:21)

  • Review Assignment 3B

      POST Method used by Form
      Audio (552K 1:10)

        <form action="http://saturn.cecs.unt.edu/cgi-bin/gjones/assign3b.cgi" method="POST">
        <P><b>Please enter the following information:</b>
            Name:           <INPUT NAME="name" TYPE="TEXT" SIZE="40">
            E-mail address: <input NAME="email" TYPE="text" SIZE="40">
            City:           <INPUT NAME="city" TYPE="TEXT" SIZE="40">
            State:          <INPUT NAME="state" TYPE="TEXT" SIZE="40">
        <b>Please input all of your grades separated by spaces:</b>
        <INPUT NAME="grades" TYPE="TEXT" SIZE="100">
        <P><b>Thank you!</b> <INPUT TYPE="SUBMIT" value="Submit Request"> <INPUT TYPE="RESET">

      Value Pairs placed in $buffer (see below)
      Audio (420K 0:54)



      Audio (128k 0:17)
      Audio (92k 00:12)
      # Print out a content-type for HTTP/1.0 compatibility
      print "Content-type: text/html\n\n";

      Audio (256k 0:33)
      # Determine where the info is coming from
        if ($ENV{'REQUEST_METHOD'} eq "POST") {
          read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
        } else {
          $buffer = $ENV{'QUERY_STRING'};

      Audio (1.7M 3:45)
      # Split the name-value pairs
      @pairs = split(/&/, $buffer);

      Audio (1.6M 3:32)
      foreach $pair (@pairs)
          ($name, $value) = split(/=/, $pair);
          # Un-Webify plus signs and %-encoding
          $value =~ tr/+/ /;
          $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
          $value =~ s/~!/ ~!/g;
          # Uncomment for debugging purposes
          #print "Setting $name to '$value'<P>";
          $FORM{$name} = $value;

      print "<html><body>";
      print "<h2>Assignment 3B (Your Name Here)</h2>";
      print "<pre>";
      print "Name:         $FORM{'name'}\n";
      print "E-Mail:       $FORM{'email'}\n";
      print "City:         $FORM{'city'}\n";
      print "State:        $FORM{'state'}\n";
      print "</pre>";
      print "<hr>";
      @grades = split (" ", $FORM{'grades'});
      #print "<hr>";print @grades; print"<hr>";
      $total = 0;
      $count = 0;
      foreach $grade (@grades) {
              #print "<p>---> $grade";
              $total += $grade;
      $average = $total / $count;
      print "<p>Your average grade is: $average<p>";
      print "</body></html>";

    Copyright 2002, Dr. James G Jones