Code :
# ! /Usr/local/bin/perl
Use CGI ' : Standard ' ;
Print header;
Print start_html (" example CGI. PM form ");
Print "
example CGI. PM form
\ n ";
print_prompt ();
do_work ();
print_tail ();
Print end_html;
Sub Print_prompt {
Print Start_form;
Print " <Em> what's your name? </Em> <br> " ;
Print Textfield ( ' Name ' );
Print Checkbox ( ' Not my real name ' );
Print " <P> <em> Where can you find English sparrows? </Em> <br> " ;
Print Checkbox_group (
-Name => ' Sparrow locations ' ,
- Values => [England, France, Spain, Asia, Hoboken],
-Linebreak => ' Yes ' ,
-Defaults => [England, Asia]);
Print " <P> <em> How far can they fly? </Em> <br> " ,
Radio_group (
-Name => ' How far ' ,
- Values => [' 10 ft ' , ' 1 mile ' , ' 10 miles ' , ' Real far ' ],
-Default => ' 1 mile ' );
Print " <P> <em> what's your favorite color? </Em> " ;
Print Popup_menu (-name => ' Color ' ,
- Values => [ ' Black ' , ' Brown ' , ' Red ' , ' Yellow ' ],
-Default => ' Red ' );
PrintHidden ('Reference','Monty Python and the Holy Grail');
Print " <P> <em> what have you got there? </Em> <br> " ;
Print Scrolling_list (
-Name => ' Possessions ' ,
- Values => [ ' A coconut ' , ' A grail ' , ' An icon ' ,
' A sword ' , ' A ticket ' ],
-Size => 5 ,
-Multiple => ' True ' );
Print " <P> <em> Any parting comments? </Em> <br> " ;
Print Textarea (-name =>' Comments ' ,
-Rows => 10 ,
-Columns => 50 );
Print " <P> " , Reset ;
Print Submit ( ' Action ' , ' Shout ' );
Print Submit (' Action ' , ' Scream ' );
Print End_form;
Print " <HR> \ n " ;
}
SubDo_work {
Print "<H2> here are the current settings in this form </H2>";
For My $ Key (PARAM ){
Print " <Strong> $ key </strong>-> " ;
My @ Values = Param ( $ Key );
Print Join ( " , " , @ Values ), " <Br> \ n " ;
}
}
SubPrint_tail {
Print<End;
<HR>
<Address> Lincoln D. Stein </address> <br>
<A href ="/"> Home page </a>
End
}
More specific form (checkbox, check_group, radio_group, popup_menu, hidden, scrolling_list, textarea...), in manpage search: http://search.cpan.org /~ Markstos/cgi. pm-3.60/lib/cgi. PM
Complete!