An eclectic mess of Perl CGI functionality:
#!/usr/bin/perl -w
use CGI;
use strict;
# Create a perlCGI object. It automatically picks up any arguments on
# the incoming URL.
my $query = new CGI;
# Create a header, and let it default arguments, it likely knows
# better then we do.
print $query->header();
# Start the body of our document, and give it a title (shows up on the
# browser bar and on printouts). All the legal fields within the HTML
# "BODY" tag are supported, and are optional. Other unsupported
# options can be specified as well, and will be correctly added. Note
# that there is nothing actually in the body tag, just HTML modifiers
# being specified.
print $query->start_html({-title=>'Form Test One...',
-author=>'Bill Kilgallon'});
print $query->hr();
# Indicate we are creating a form.
# For this example, everything defaults. We will flesh it out later.
print $query->startform({-method=>'post'});
# print $query->startform({-method=>'get'});
# Generate a text field for data entry
print $query->h1('Please enter some text');
print $query->textfield({-name=>'TextfieldOne',
-default=>'Enter your text here',
-size=>50,
-maxlength=>100});
print $query->br();
# Generate a text area for data entry
print $query->h1('Please enter some more text');
print $query->textarea({-name=>'TextareaOne',
-default=>'Enter lots of your text here',
-rows=>4,
-columns=>60});
print $query->br();
# Generate a password area
print $query->h1('Please enter some secret text');
print $query->password_field({-name=>'PasswordareaOne',
-default=>'Your Password',
-size=>10,
-maxlength=>60});
print $query->br();
# Generate a popup menu
print $query->h1('Choose from the following menu');
print $query->popup_menu({-name=>'PopupOne',
-values=>['First Choice', 'Second Choice',
'Third Choice', 'Fourth Choice',
'Fifth Choice'],
-defaults=>'Fifth Choice'});
print $query->br();
# Generate a scrolling list
print $query->h1('Choose from the following list');
print $query->scrolling_list({-name=>'ScrolllistOne',
-values=>['First Choice', 'Second Choice',
'Third Choice', 'Fourth Choice',
'Fifth Choice'],
-multiple=>'true',
-defaults=>'Fifth Choice'});
print $query->br();
# Generate a checkbox for selecting zero or more elements from a list
print $query->checkbox_group({-name=>'CheckboxOne',
-values=>['First Box','Second Box', 'Third Box',
'Fourth Box', 'Fifth Box'],
-defaults=>['Second Box','Fifth Box']});
print $query->br();
# Generate a standalone checkbox, initialize checked
print $query->checkbox({-name=>'CheckboxAloneOne',
-checked=>'checked'});
print $query->br();
# Generate a Radio Group
print $query->h1('Choose only one from the following list');
print $query->radio_group({-name=>'RadioOne',
-values=>['First Choice', 'Second Choice',
'Third Choice', 'Fourth Choice',
'Fifth Choice'],
-default=>'Second Choice'});
print $query->br();
# Generate a submit button for this form
print $query->submit();
# Generate a reset button for this form
print $query->reset();
print $query->endform();
print $query->hr();
# Now conditionally report what the user typed in previously.
# If this is not the first time into the script...
if ($query->param()) {
# Extract out whatever the contents of our text field were.
my $textInput = $query->param(-name=>'TextfieldOne');
print $query->hr();
print $query->p('The textfield entered was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Extract out whatever the contents of our text area were.
my $textInput = $query->param(-name=>'TextareaOne');
print $query->hr();
print $query->p('The textarea entered was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Extract out whatever the contents of our password area were.
my $textInput = $query->param(-name=>'PasswordareaOne');
print $query->hr();
print $query->p('The Password entered was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Extract out whatever the contents of our popup area were.
my $textInput = $query->param(-name=>'PopupOne');
print $query->hr();
print $query->p('The popup selected was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Extract out whatever the scrolling list was
my @textInput = $query->param(-name=>'ScrolllistOne');
print $query->hr();
print $query->p('The scrolling list selects were:'), $query->br();
print $query->em({-align=>'center'}, @textInput);
print $query->hr();
# Extract out whatever the contents of our checkbox were.
my @textInput = $query->param(-name=>'CheckboxOne');
print $query->hr();
print $query->p('The checkbox entries you selected were:'), $query->br();
print $query->em({-align=>'center'}, @textInput);
print $query->hr();
# Extract out whatever the state of the standalone checkbox was.
# (Either "on" or an empty string)
my $textInput = $query->param(-name=>'CheckboxAloneOne');
print $query->hr();
print $query->p('The checkboxalone state was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Extract out whatever the radio group was
my $textInput = $query->param(-name=>'RadioOne');
print $query->hr();
print $query->p('The radio group select was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Generate my URL
print $query->br("My full URL:", $query->url() );
print $query->br("My relative URL:", $query->url(-relative=>1) );
print $query->br("My absolute URL:", $query->url(-absolute=>1) );
print $query->br("My URL with path:", $query->url(-path_info=>1) );
print $query->br("My URL with path and query info:",
$query->url(-path_info=>1, -query=>1) );
print $query->hr();
}
# And finally, end the document.
print $query->end_html;