#!/usr/local/bin/perl
     
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
 
$query = new CGI;

print $query->header;
print $query->start_html("Example CGI.pm Form");
print "
 Example CGI.pm Form
\n";
&print_prompt($query);
&do_work($query);
&print_tail;
print $query->end_html;
 
sub print_prompt {
   my($query) = @_;
 
   print $query->start_form;
   print "What's your name?
";
   print $query->textfield('name');
   print $query->checkbox('Not my real name');
 
   print "<P>Where can you find English Sparrows?
";
   print $query->checkbox_group(
				-name=>'Sparrow locations',
				-Values=>[England,France,Spain,Asia,Hoboken],
				-linebreak=>'yes',
				-defaults=>[England,Asia]);
 
   print "<P>How far can they fly?
",
   $query->radio_group(
		       -name=>'how far',
		       -Values=>['10 ft','1 mile','10 miles','real far'],
		       -default=>'1 mile');
   
   print "<P>What's your favorite color?  ";
   print $query->popup_menu(-name=>'Color',
			    -Values=>['black','brown','red','yellow'],
			    -default=>'red');
 
   print $query->hidden('Reference','Monty Python and the Holy Grail');
 
   print "<P>What have you got there?
";
   print $query->scrolling_list(
				-name=>'possessions',
				-Values=>['A Coconut','A Grail','An Icon',
					  'A Sword','A Ticket'],
				-size=>5,
				-multiple=>'true');
 
   print "<P>Any parting comments?
";
   print $query->textarea(-name=>'Comments',
			  -rows=>10,
			  -columns=>50);
   
   print "<P>",$query->reset;
   print $query->submit('Action','Shout');
   print $query->submit('Action','Scream');
   print $query->endform;
   print "
\n";
 	}
 
sub do_work {
    my($query) = @_;
    my(@values,$key);

    print "<H2>Here are the current settings in this form</H2>";

    foreach $key ($query->param) {
	print "<STRONG>$key</STRONG> -> ";
	@values = $query->param($key);
	print join(", ",@values),"<BR>\n";
    }
}
 
sub print_tail {
    print <<END;

Lincoln D. Stein

Home Page
END
    ;
}
