#!/usr/bin/perl use strict; use warnings; my %inventory; my $maxRNG = 6; my $RNG = rand($maxRNG); my $name = ""; while($name eq "") { print "May I have your name please? "; chomp($name = <>); } print "Thank you $name.\n"; while(1) { print "Please enter a difficulty level: easy or hard? "; chomp(my $diff = <>); if ($diff eq "easy"){ $inventory{wood} = 120; $inventory{food} = 50; last; } elsif ($diff eq "hard"){ $inventory{wood} = 75; $inventory{food} = 20; last; } else { next; } print "You chose $diff.\n"; } print "You have crash landed on a strange alien planet and must find a way to get back to earth.\n"; print "\n"; print "You have:\n"; foreach my $item (sort keys %inventory) { print " $inventory{$item} $item\n"; } print "You can:\n"; if($inventory{wood} >= 10){ print "BUILD a HUT with 10 wood\n"; }