return to first page linux journal archive
keywordscontents

Listing 4. Using Hash Keys

#!/usr/bin/perl -w
# -w warning on errors
# CGI-BIN program to process parameter input
# GET method to extract parameter strings
use strict;
use diagnostics;
use CGI_Lite;
# 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";
# Put the form data into a hash
my %FORM = $query->parse_form_data;
# Get the keys in %FORM
my @keys = keys %FORM;
# Get the first key, which will be the query 
# string
my $query_string = $keys[0];
print "<P>Hello, $query_string</P>\n";
print "</Body></HTML>\n";