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

# File Name: drylstcr.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("

The data received was:

\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); # foreach $temp (@fields) { # print ("$temp
"); # } # # first letter of botanical name # $letter = $fields[0]; # # get rid of letter= # $letter =~ s/letter=//; # # blanks in the original lead to +'s # # # get rid of leading pluses # $letter =~ s/^[\+]+//; # # get rid of trailing pluses # $letter =~ s/[\+]+$//; # # translate upper case to lower case # $letter =~ tr/A-Z/a-z/; # print ("$letter
"); $errflag = 0; if ($letter eq "y") { $errflag = 1; print("
Currently, the data file contains no names that begin with a y.
"); } if ($letter !~ /^[a-z]/) { $errflag = 1; print("
You must supply a letter.
"); } if (length($letter) > 1) { $errflag = 1; print("
You must supply exactly 1 letter.
"); } if ($errflag != 1) { print("

WWW Drying Schedule Computer Program

"); print("

What is the botanical name of the species?

"); @list = ($letter,"dry.dat"); $datafile = join("",@list); if (open(DATA,$datafile)) { print("

"); print("

"); print("


What is the thickness?

"); print("25 to 38 mm
"); print("50 mm
"); print("

"); print("

"); print("

"); print("

For further information, please contact Steve Verrill at steve\@www1.fpl.fs.fed.us or 608-231-9375.
"); print("Last modified on 4\/15\/01."); } else { print("
ERROR: The species name data file could not be opened. Please contact Steve Verrill at steve\@www1.fpl.fs.fed.us or 608-231-9375.

"); } } } 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; }