%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 "