/usr/share/perl5/CGI/examples
NameSizeModeActions
WORLD_WRITABLE/-0755rm
caution.xbm7410644editdlrm
clickable_image.cgi8080644editdlrm
cookie.cgi22630644editdlrm
crash.cgi1310644editdlrm
customize.cgi24540644editdlrm
diff_upload.cgi15950644editdlrm
file_upload.cgi19980644editdlrm
frameset.cgi20760644editdlrm
index.html34870644editdlrm
internal_links.cgi10190644editdlrm
javascript.cgi30490644editdlrm
make_links.pl1960644editdlrm
monty.cgi20860644editdlrm
multiple_forms.cgi15990644editdlrm
nph-clock.cgi3590644editdlrm
nph-multipart.cgi2630644editdlrm
popup.cgi10240644editdlrm
save_state.cgi23110644editdlrm
tryit.cgi7800644editdlrm
Edit: /usr/share/perl5/CGI/examples/customize.cgi (2454B)
#!/usr/local/bin/perl use CGI qw(:standard :html3); # Some constants to use in our form. @colors=qw/aqua black blue fuschia gray green lime maroon navy olive purple red silver teal white yellow/; @sizes=("",1..7); # recover the "preferences" cookie. %preferences = cookie('preferences'); # If the user wants to change the background color or her # name, they will appear among our CGI parameters. foreach ('text','background','name','size') { $preferences{$_} = param($_) || $preferences{$_}; } # Set some defaults $preferences{'background'} = $preferences{'background'} || 'silver'; $preferences{'text'} = $preferences{'text'} || 'black'; # Refresh the cookie so that it doesn't expire. This also # makes any changes the user made permanent. $the_cookie = cookie(-name=>'preferences', -value=>\%preferences, -expires=>'+30d'); print header(-cookie=>$the_cookie); # Adjust the title to incorporate the user's name, if provided. $title = $preferences{'name'} ? "Welcome back, $preferences{name}!" : "Customizable Page"; # Create the HTML page. We use several of Netscape's # extended tags to control the background color and the # font size. It's safe to use Netscape features here because # cookies don't work anywhere else anyway. print start_html(-title=>$title, -bgcolor=>$preferences{'background'}, -text=>$preferences{'text'} ); print basefont({SIZE=>$preferences{size}}) if $preferences{'size'} > 0; print h1($title),<'name', -default=>$preferences{'name'}, -size=>30),br, table( TR( td("Preferred"), td("Page color:"), td(popup_menu(-name=>'background', -values=>\@colors, -default=>$preferences{'background'}) ), ), TR( td(''), td("Text color:"), td(popup_menu(-name=>'text', -values=>\@colors, -default=>$preferences{'text'}) ) ), TR( td(''), td("Font size:"), td(popup_menu(-name=>'size', -values=>\@sizes, -default=>$preferences{'size'}) ) ) ), submit(-label=>'Set preferences'), hr; print a({HREF=>"/"},'Go to the home page'); print end_html;