Please send questions to st10@humboldt.edu .
#!/usr/bin/perl -w

#######################################################
# lect10_03.pl
#
# will this save the info from the form on lect10_03.html,
#    and demonstrate some more CGI.pm functions?
#
# by Sharon Tuttle 
#
# last modified: 11-02-04
#######################################################

#1
use CGI qw(:standard);

open HTML_INFO, ">> lect10_03_sent_info"
   or die "Cannot open lect10_03_sent_info: $!";

#2
# "The CGI module will automatically parse any provided data.
#    The param() function provides access to the parameters
#    (name-value pairs) passed to the script.
# If param() is called without any arguments, it returns a
#    list of all the names....
# If it is called with a single argument, it returns the
#    value or values associated with that name, if any."
# [Practical Perl with CGI Applications, Chang, p. 161]
#
# # first: get the information from the HTML form as one big string:
#
# if (exists $ENV{"CONTENT_LENGTH"})
# {
#     read STDIN, $info_string, $ENV{"CONTENT_LENGTH"}; 
# }
# else
# {
#     $info_string = "EMPTY";
# }
#
# # try to save it to lect09_03_sent_info:
#
# print HTML_INFO "$info_string\n";
#

# let's write the parameters sent:
my @parameters_sent = param;

# let's write each parameter and its value, on its own line,
#    to HTML_INFO
foreach $parameter (@parameters_sent)
{
    print HTML_INFO "$parameter -> ", param($parameter), "\n";
}

close HTML_INFO;

# try to send back a confirmation page

#3
# print "Content-type: text/html", "\n\n";
# print "<html>\n";
# print "<head><title>Confirmation</title></head>\n";
# print "<body><h1>Confirmation</h1>\n";

print header, "\n";
print start_html(-title=>'Confirmation'), "\n";

print "<h1>Confirmation</h1>\n";

print "<hr>\n";
print "Information transferred?\n";

#4 
# oh, what the heck --- why wait???

print "<br>";    # to force a line break
foreach $parameter (@parameters_sent)
{
    print "$parameter => ", param($parameter), " <br> \n";
}

#5
# print "</body>\n";
# print "</html>\n";

print end_html, "\n";

# end of lect10_03.pl