LJ Archive

Listing 3. Second Version of Perl Program hello.pl

#!/usr/bin/perl -w
# -w warning on errors
# CGI-BIN program to process web forms-input date.
# POST method to extract parameter strings.
# multiple values extracted from hash (associative
# array).
use diagnostics;
use CGI_Lite;
# Commenting out this line allows "firstname" to
# be defined by create_variables later
my $firstname = "NOT CHANGED";
# Create an instance of CGI_Lite
my $query = new CGI_Lite;
# Send an appropriate MIME header to the browser
print "Content-type: text/html\n\n";
# Send the beginning HTML
print "<HTML><Head><Title>Hello!</Title>\n";
print "</Head></Body>\n";
# Get the form data into a hash
my %FORM = $query-%gt;parse_form_data;
$query->create_variables(\%FORM);
print "<P>Hello, $firstname</P>\n";
print "</Body></HTML>\n";
LJ Archive