#!/usr/bin/perl -wT use strict; #the line above tells CGI where to find the perl interpreter use CGI qw(:standard); #this calls CGI library functions for perl use CGI::Carp qw(warningsToBrowser fatalsToBrowser); my %colors = ( red => "#ff0000", #an associative array of colors green => "#00ff00", blue => "#0000ff", gold => "#cccc00"); print header; my $color = param('color'); #this gets the selected color from the form # do some validation - be sure they picked a valid color if (exists $colors{$color}) { print start_html(-title=>"Results", -bgcolor=>$color); #note that the CGI library functions create HTML for you! print "You picked $color.
\n"; } else { print start_html(-title=>"Results"); print "You didn't pick a color! (You picked '$color')"; } print end_html; #be sure and view the HTML source of the return from the CGI