%states = ( 'default' => \&front_page, 'Shirt' => \&shirt, 'Sweater' => \&sweater, ); $current_screen = param(".state") || "default"; die "No screen for $current_screen" unless states{$current_screen}; # Generate the current page. standard_header(); #how does this while loop work? while (my($screen_name, $function) = each %states) { $function->($screen_name eq $current_screen); } standard_footer(); exit; ############################# # subroutines for each screen ############################# # The default page. sub front_page { my $active = shift; return unless $active; # how do the above 2 lines work? print "

Hi!

\n"; print "Welcome to our Shirt Shop! Please make your selection from "; print "the menu below.\n"; shop_menu(); } # Page to order a shirt from. sub shirt { my $active = shift; #what does this line do? my @sizes = qw(XL L M S); my @colors = qw(Black White); my ($size, $color, $count) = (param("shirt_size"), param("shirt_color"), param("shirt_count")); ... yada yada