#!/usr/bin/perl require 5.002; use strict; no strict qw(refs); use CGI; use CGI::Carp qw(carpout); $| = 1; $\ = "\n"; my $q = CGI->new(); my @ROOMS = qw(checkout greenery butcher dairy layaway); my $room; my $WIDGET = "scrolling_list"; ######## my $WIDGET = "checkbox_group"; use vars qw(@greenery @dairy @butcher); @greenery = sort split /\s*\n\s*/, <header(); carpout(\*STDOUT); print $q->start_html( -AUTHOR => 'tchrist@perl.com', -TITLE => "Tom's Self-Service Pizza Shoppe", ); head("Tom's Self-Service Pizza Shoppe"); print "
"; # print h1("Here I am"); print $q->startform(); unless ( $q->param() ) { welcome(); } else { $room = lc $q->param("room"); if (defined &$room) { &$room; } else { die "No such room $room"; } } print $q->endform(); print $q->end_html(); exit 0; ######################################################## sub head { center(); print "

@_

"; uncenter(); } sub shead { # center(); print "

@_

"; # uncenter(); } sub greenery { shead("Green Grocer"); show_rooms(); } sub butcher { shead("Animal Parts"); show_rooms(); } sub checkout { shead("Checkout Counter"); show_rooms(); } sub dairy { shead("Dairy Goods"); show_rooms(); } sub welcome { shead("Welcome Room"); print <<'EOS'; Welcome to the Tom's Roll-your-own Pizza shoppe! Please select from any of the following rooms: EOS show_rooms(); } sub show_rooms { my $place; center(); foreach $place (@ROOMS) { if (@$place) { my $method = ($room eq $place) ? $WIDGET : "hidden"; print $q->$method( -NAME => $place, -VALUES => [ @$place ], -DEFAULT => [], -MULTIPLE => 1, -SIZE => 4, -ROWS => 3, -COLUMNS => 3, ); } } uncenter(); print "
"; my $selections = 0; shead("Current Selections"); print "
"; foreach $place (@ROOMS) { next if $place eq $room; print "
"; print $q->submit(-NAME => "room", -VALUE => ucfirst($place), ); my @choices = $q->param($place); print "
", join(', ', @choices) if @choices; } print "
"; } sub layaway { head("Lawayay Counter"); } sub center { print "
" if netscape(); } sub uncenter { print "
" if netscape(); } { my $browser; sub netscape { $browser ||= $q->user_agent; return $browser =~ /Mozilla/; } }