Created
October 25, 2016 21:44
-
-
Save 0racle/e7ae2b0a176774ad0d85b42d6607f8f6 to your computer and use it in GitHub Desktop.
Guessing Game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
say "Guess the number!"; | |
my $secret_number = (1..100).pick; | |
loop { | |
my $guess = prompt("Please input your guess: ").Int or next; | |
say "You guessed: $guess"; | |
given $guess <=> $secret_number { | |
when Less { say "Too small!" } | |
when More { say "Too big!" } | |
when Same { | |
say "You win!"; | |
last; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment