sub a { print @_, "\n"; my \$r = ; if (\$r =~ /y/i) { return 1; } elsif (\$r =~ /n/i) { return 0; } else { print "Sorry, I don't understand that. Please answer Y/N.\n"; a(@_); } } sub t { print "What is your animal?\n"; my \$ans = ; chomp(\$ans); return \$ans; } sub i { my (\$guessed, \$user_answer) = @_; chomp(\$guessed, \$user_answer); print "Please enter a question that would be true for a " . "\$user_answer, but false for a \$guessed:\n"; my \$ans = ; chomp(\$ans); return \$ans; } sub w { if (a("\nDo you want to continue?")) { print "\nStarting a new game.\n"; } else { print "BYE!\n"; exit(); } } ##```## \$Q{a}="golfer"; ##``````## # 1 2 3 4 5 6 7 8 9 10 11 #123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_1234567 {*q=\%Q;*q=\$q{a\$q{q}}while\$q{q};\$q{0}{a}=\$q{a},\$q{1}{a}=t,\$q{q}=i(\$q{a},\$q{1}{a})if!a"Is your animal a \$q{a}?";w,redo} # Was #{*q=*Q;*q=\$q{a\$q{q}}while\$q{q};\$q{0}{a}=\$q{a},\$q{1}{a}=t,\$q{q}=i(\$q{a},\$q{1}{a})if!a"Is your animal a \$q{a}?";w&&redo} ```