!/usr/bin/perl
# This is the password program, used to learn a little about
# Perl, by making a little game. The computer generates a simple
# password, the user has to guess it.

print "Password. The script will create a password, you have\n";
print "to guess it. Possible passwords are foo and bar.\n";

$password = "";
$input = "";

if (rand() > 0.5) {
$password = 'foo';
}
else {
$password = 'bar';
}

print "Make a guess: ";
$input = <>;

while ($input ne $password) {
print "\nIncorrect. Try again!\n";
#print "input = $input";
#print "password = $password\n";
print "Make a guess: ";
$input = <>;
}

print "Correct answer!";
#end

It never breaks out of the loop. I added in the now commented-out print statements to make sure $password and $input did indeed match and... yep. It just doesn't seem to recognize it.

I'm tired, so if it turns out to be a really obvious mistake, that's why.

Oh, and I'm running on win2k (added the shebang line because I figure it's a good habit to get into) and using ActivePerl.