Skip to content

Instantly share code, notes, and snippets.

@xenoterracide
Created April 18, 2010 23:26
Show Gist options
  • Save xenoterracide/370613 to your computer and use it in GitHub Desktop.
Save xenoterracide/370613 to your computer and use it in GitHub Desktop.
Guess a number game
#!/usr/bin/env perl
# guess a number game
use feature 'say';
use strict;
use warnings;
say "welcome";
my $guess = 0;
until ( $guess == 5 ) {
say "Guess the number: ";
$guess = readline(*STDIN);
if ( $guess == 5 ) {
say "You Win!";
}
elsif ( $guess > 5 ) {
say "Too high";
}
else {
say "Too low";
}
}
say "Game over!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment