(my $guess = <STDIN>); 'my' is your problem.. that creates new varialbe remove it.. HTH Jay
-----Original Message----- From: Greg Donald [mailto:[EMAIL PROTECTED] Sent: Thursday, April 15, 2004 11:41 AM To: [EMAIL PROTECTED] Subject: guessing script Learning Perl here.. So I wrote this number guessing script but can't see what is wrong with it. I can never get the solution even when I know it's correct. What am I doing wrong? #!/usr/bin/env perl use Math::Random; use strict; sub run(){ my $solution = random_uniform_integer(1, 1, 100); my $guess = undef; do { print "\$solution = $solution\n"; print "Guess (1 - 100) ?\n"; chomp(my $guess = <STDIN>); if ($guess > $solution) { print "$guess is too HIGH!\n"; } if ($guess < $solution) { print "$guess is too LOW!\n"; } } while ($guess != $solution); print "$guess is correct, YAY!\n"; print "Play again? "; chomp(my $answer = <STDIN>); if (lc($answer) eq 'y') { run(); } } run(); TIA :) -- Greg Donald [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>