home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 December (Special) / PCWorld_2005-12_Special_cd.bin / Bezpecnost / lsti / lsti.exe / framework-2.5.exe / monty.cgi < prev    next >
Text File  |  2005-01-27  |  2KB  |  85 lines

  1. #!/usr/local/bin/perl
  2.      
  3. use CGI;
  4. use CGI::Carp qw/fatalsToBrowser/;
  5.  
  6. $query = new CGI;
  7.  
  8. print $query->header;
  9. print $query->start_html("Example CGI.pm Form");
  10. print "<H1> Example CGI.pm Form</H1>\n";
  11. &print_prompt($query);
  12. &do_work($query);
  13. &print_tail;
  14. print $query->end_html;
  15.  
  16. sub print_prompt {
  17.    my($query) = @_;
  18.  
  19.    print $query->start_form;
  20.    print "<EM>What's your name?</EM><BR>";
  21.    print $query->textfield('name');
  22.    print $query->checkbox('Not my real name');
  23.  
  24.    print "<P><EM>Where can you find English Sparrows?</EM><BR>";
  25.    print $query->checkbox_group(
  26.                 -name=>'Sparrow locations',
  27.                 -Values=>[England,France,Spain,Asia,Hoboken],
  28.                 -linebreak=>'yes',
  29.                 -defaults=>[England,Asia]);
  30.  
  31.    print "<P><EM>How far can they fly?</EM><BR>",
  32.    $query->radio_group(
  33.                -name=>'how far',
  34.                -Values=>['10 ft','1 mile','10 miles','real far'],
  35.                -default=>'1 mile');
  36.    
  37.    print "<P><EM>What's your favorite color?</EM>  ";
  38.    print $query->popup_menu(-name=>'Color',
  39.                 -Values=>['black','brown','red','yellow'],
  40.                 -default=>'red');
  41.  
  42.    print $query->hidden('Reference','Monty Python and the Holy Grail');
  43.  
  44.    print "<P><EM>What have you got there?</EM><BR>";
  45.    print $query->scrolling_list(
  46.                 -name=>'possessions',
  47.                 -Values=>['A Coconut','A Grail','An Icon',
  48.                       'A Sword','A Ticket'],
  49.                 -size=>5,
  50.                 -multiple=>'true');
  51.  
  52.    print "<P><EM>Any parting comments?</EM><BR>";
  53.    print $query->textarea(-name=>'Comments',
  54.               -rows=>10,
  55.               -columns=>50);
  56.    
  57.    print "<P>",$query->reset;
  58.    print $query->submit('Action','Shout');
  59.    print $query->submit('Action','Scream');
  60.    print $query->endform;
  61.    print "<HR>\n";
  62.      }
  63.  
  64. sub do_work {
  65.     my($query) = @_;
  66.     my(@values,$key);
  67.  
  68.     print "<H2>Here are the current settings in this form</H2>";
  69.  
  70.     foreach $key ($query->param) {
  71.     print "<STRONG>$key</STRONG> -> ";
  72.     @values = $query->param($key);
  73.     print join(", ",@values),"<BR>\n";
  74.     }
  75. }
  76.  
  77. sub print_tail {
  78.     print <<END;
  79. <HR>
  80. <ADDRESS>Lincoln D. Stein</ADDRESS><BR>
  81. <A HREF="/">Home Page</A>
  82. END
  83.     ;
  84. }
  85.