Hi list, Thank you all who responded to my question and in particular Dr MindHacker. After I saw the corrected code, I realized how I am supposed to "think" in perl.
Thank you very much. Danny > > Danny, > The code is below, I ran a simple test and > it worked. The "Please choose ..." part should > be at top because that will always execute so > long as the final elseif path is not executed... > Also, the other $guess = <STDIN> were simply > redundant after this fix so I removed them. > > Dr MindHacker > > #!/usr/bin/perl -w > > $upper = 20 ; > $lower = 1 ; > $target = 11 ; > > while ( ) > { > print "Please choose a number between ${lower} and > ${upper}\n" ; > $guess = <STDIN>; > if ( $guess > $target ) > { print "Too high\n" ; } > elsif ( $guess < $target ) > { print "Too low\n" ; } > elsif ( $guess == $target ) > { > print "You guessed right\n" ; > exit ; > } > } > > Dr MindHacker -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>