#!/usr/local/bin/perl use CGI; $query = new CGI; $CGI::POST_MAX = 102400; # set maximum size of post 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->startform; print "What's your name?
"; print $query->textfield('name'); print $query->checkbox('Not my real name'); print $query->filefield('uploaded_file','starting value',50,80); # ACCEPT="filetype/*" print "

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 "

How far can they fly?
", $query->radio_group( -name=>'how far', -values=>['10 ft','1 mile','10 miles','real far'], -default=>'1 mile'); print "

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 "

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 "

Any parting comments?
"; print $query->textarea(-name=>'Comments', -rows=>10, -columns=>50); print "

",$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 "

Here are the current settings in this form

"; foreach $key ($query->param) { print "$key -> "; @values = $query->param($key); print join(", ",@values),"
\n"; } } sub print_tail { $filename = $query->param('uploaded_file'); print "

$filename
\n\n"; # Read a text file and print it out # while (<$filename>) { # print; # } $type = $query->uploadInfo($filename)->{'Content-Type'}; print "

$type
\n\n"; # unless ($type eq 'text/html') { # die "HTML FILES ONLY!"; # } print "

fini
\n\n"; # Copy a binary file to somewhere safe open (OUTFILE,">/tmp.vbe"); while ($bytesread=read($filename,$buffer,1024)) { print OUTFILE $buffer; } print "

fini
\n\n"; print <
Lincoln D. Stein

Home Page END }