3 use CGI qw(:standard :html3);
5 # Some constants to use in our form.
6 @colors=qw/aqua black blue fuschia gray green lime maroon navy olive
7 purple red silver teal white yellow/;
8 @sizes=("<default>",1..7);
10 # recover the "preferences" cookie.
11 %preferences = cookie('preferences');
13 # If the user wants to change the background color or her
14 # name, they will appear among our CGI parameters.
15 foreach ('text','background','name','size') {
16 $preferences{$_} = param($_) || $preferences{$_};
20 $preferences{'background'} = $preferences{'background'} || 'silver';
21 $preferences{'text'} = $preferences{'text'} || 'black';
23 # Refresh the cookie so that it doesn't expire. This also
24 # makes any changes the user made permanent.
25 $the_cookie = cookie(-name=>'preferences',
26 -value=>\%preferences,
28 print header(-cookie=>$the_cookie);
30 # Adjust the title to incorporate the user's name, if provided.
31 $title = $preferences{'name'} ?
32 "Welcome back, $preferences{name}!" : "Customizable Page";
34 # Create the HTML page. We use several of Netscape's
35 # extended tags to control the background color and the
36 # font size. It's safe to use Netscape features here because
37 # cookies don't work anywhere else anyway.
38 print start_html(-title=>$title,
39 -bgcolor=>$preferences{'background'},
40 -text=>$preferences{'text'}
43 print basefont({SIZE=>$preferences{size}}) if $preferences{'size'} > 0;
45 print h1($title),<<END;
46 You can change the appearance of this page by submitting
47 the fill-out form below. If you return to this page any time
48 within 30 days, your preferences will be restored.
57 textfield(-name=>'name',
58 -default=>$preferences{'name'},
65 td(popup_menu(-name=>'background',
67 -default=>$preferences{'background'})
73 td(popup_menu(-name=>'text',
75 -default=>$preferences{'text'})
81 td(popup_menu(-name=>'size',
83 -default=>$preferences{'size'})
88 submit(-label=>'Set preferences'),
91 print a({HREF=>"/"},'Go to the home page');