#!/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("