#!/usr/local/bin/perl
# This was copied from pages 342 and 343 of the book
# Build a Web Site.

# File Name: drying.pl

local($request_method,$content_length,$query_string);

#
#   This assignment ensures that there are not problems in
#   mixing fortran output with perl output.
#

$| = 1;

#Grab REQUEST_METHOD, CONTENT_LENGTH, and QUERY_STRING

$request_method = $ENV{'REQUEST_METHOD'};
$content_length = $ENV{'CONTENT_LENGTH'};
$query_string = $ENV{'QUERY_STRING'};

#Check whether this was a PUT or a POST

if (($request_method eq 'POST') || ($request_method eq 'PUT')) {

#If so, read the appropriate number of bytes from STDIN

   read(STDIN, $query, $content_length);

#echo these bytes 

   print("Content-Type: text/html\n\n");

#   print("

Today we are debugging.

\n\n"); # print("

\n"); # print("$query



"); # # The material below was written by Steve Verrill, 6/96 # #Try to parse $query. & separates fields. + separates multiple items in a field. @fields = split(/&/, $query); # print ("@fields

"); # foreach $temp (@fields) { # print ("$temp
"); # } # print("

"); # # specific gravity # $errflag = 0; # $fields[0] =~ s/[^\d]//g; # $sg = $fields[0]; # print("sg = $sg
"); # # pluses in the original input create %2B's. Handle. # $fields[0] =~ s/%2B/\+/g; # # get rid of everything other than minus signs, plus signs, decimals, # and digits # $fields[0] =~ s/[^-\+\.\d]//g; # # get rid of leading pluses # $fields[0] =~ s/^[\+]+//; # # get rid of trailing pluses # $fields[0] =~ s/[\+]+$//; $sg = $fields[0]; print("Return to Drying Program home page.


"); print("Specific gravity = $sg
"); $thick = $fields[1]; # # Get rid of thick= # $thick =~ s/thick=//; if ($thick == 2538) { print("The thickness is from 25 to 38 mm

"); if ($errflag != 1) { @proglist = ("drying","$sg","$thick"); system(@proglist); } } elsif ($thick == 50) { print("The thickness is 50 mm

"); if ($errflag != 1) { @proglist = ("drying","$sg","$thick"); system(@proglist); } } else { print("No thickness was specified. Please"); print(" try again."); } print("



For further information, please contact Steve Verrill at steve\@www1.fpl.fs.fed.us or 608-231-9375.
"); print("Last modified on 4\/25\/01."); # print("

"); # print("@fields
"); } elsif ($request_method eq 'GET') { #If so, the data is in QUERY_STRING $query = $query_string; } else { #Otherwise, print an error print("Content-Type: text/html\n\n"); print("

Error: Unacceptable Method

\n\n"); print("
\n"); print("This script does not support the $ENV{'REQUEST_METHOD'}\n"); print("method for submitting forms. Please use the POST method.\n"); exit; }