sub process_command { print "\n\n:"; chomp ($command = ); $command =~ tr/A-Z/a-z/; if ($currentRoom == HALLWAY) { hallwayCommand(); } elsif ($currentRoom == BEDROOM) { bedroomCommand(); } ... etcetera ... } #### $currentRoom = HALLWAY; return; #### if ($uniform == HAVE) { print "\n\nOne slightly uncomfortable uniform."; } if ($keyCard == HAVE) { print "\n\nYour access keycard."; } if ($lighter == HAVE) { print "\n\nOne old lighter."; } if ($closetKey == HAVE) { print "\n\nThe key to the utility closet."; } #### # At start of program, set up the starting location and description of each object my $Objects = ( light => { location=>BEDROOM, description=>'The chair in front of your desk has your uniform slung over it', }, keycard => { location=>BEDROOM, description=>'Your keycard sits on the desk', } ... etcetera ... }; sub display_items_in_location { my $loc_to_display = shift; for my $item (keys %Objects) { if ($Objects{$item}{location} == $loc_to_display) { print $Objects{$item}{location}; } } } #### sub bedroomCommand { ... elsif ($light == TRUE) { print "The sleeping quarters are quite small.... display_items_in_location(BEDROOM); print "There are no paintings or posters on the wall... sleep 5; } #### elsif ($command =~ "keycard" or $command =~ "take keycard" ... ... elsif ($light == TRUE) { if ($Objects{keycard}{location} == HAVE) { print "You already have it.\n\n"; sleep 2; return; # from my first comment } else { print "You pick up the keycard.\n..... sleep 2; $Objects{keycard}{location} = HAVE; $Objects{keycard}{description} = 'Your access keycard.';