Skip to content

Instantly share code, notes, and snippets.

@0racle
Created October 25, 2016 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0racle/e7ae2b0a176774ad0d85b42d6607f8f6 to your computer and use it in GitHub Desktop.
Save 0racle/e7ae2b0a176774ad0d85b42d6607f8f6 to your computer and use it in GitHub Desktop.
Guessing Game
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