#!/usr/local/bin/perl ## ## Print tags for beginng of HTML document to STDOUT ## print < Welcome to the JDC

Welcome to the JDC

EOM

############################################################
print "\n

Debug Info

\n"; $content_length = $ENV{'CONTENT_LENGTH'}; print "content_length: " , $content_length, "\n"; ## ## Read the parameters passed by the HTML form ## from the QUERY_STRING environment variable. ## $query_string = $ENV{'QUERY_STRING'}; print "query_string: ", $query_string, "\n"; ## ## Decode the form data encoded in the URL. ## $query_string =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; $query_string =~ s/\+/ /g; print "query_string (decoded): ", $query_string, "\n"; print "\n"; ## ## Break up the parameters passed in the URL into an ## array of key-value pairs. ## @pairs = split (/&/, $query_string); print "pairs :", @pairs, "\n"; print "pairs[0] :", $pairs[0], "\n"; print "pairs[1] :", $pairs[1], "\n"; ## ## Iterate over the array of key-value pairs, ## break up each pair into key component and ## value component. Build hashtable, called ## form_data, allowing values to retrieved ## using name key. ## foreach $pair (@pairs) { print "pair: ", $pair, "\n"; ($key, $value) = split (/=/, $pair); print "key: ", $key, " value: ", $value, "\n"; $form_data{$key} = $value; } print "\n%form_data: ", %form_data, "\n"; print "\nContents of %form_data hash table\n"; foreach $key (keys %form_data) { print " $key: $form_data{$key}\n"; } ## ## Now parameter values can be retrieved from the ## hashtable by supplying a name key. ## $firstname = $form_data{"firstname"}; $lastname = $form_data{"lastname"}; ## ## This is the dynamic content generated in ## response to the HTML form submission. ## print "\n

Greetings

\n"; print "Hello $firstname $lastname. Welcome to the JDC.\n\n"; ############################################################ ## ## Print tags for end of HTML document to STDOUT ## print < EOM close OUT;