Hi err, Mr T.

Here's a solution to your question, but from a different point of view...

--------------------------
  #!perl -w
  use strict;

 my $im_thinking_of = int(rand 10);
 my $guess;

 do {
     print "Pick a number:";
     $guess = <STDIN>;
     chomp $guess;

     if ($guess > $im_thinking_of) {print "You guessed too high!\n";}
     if ($guess < $im_thinking_of) {print "You guessed too low!\n";}
 } while ($guess != $im_thinking_of);

 print "You got it right!\n";
-----------------------------

I think this works better because the main loop of the program is
conditioned on what we're actually looking for. ie, we'll keep going until
the number is guessed correctly. Also, this way, you don't need to jump out
of the loop half way through, which (I think) should be discouraged where
possible (it doesn't always make sense)

But hey, I'm just one programmer, what do I know?

Cheers

Rob

"Mr.T Mr.X" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> #!/user/bin/perl -w
>
> $im_thinking_of=int(rand 10);
>       print "Pick a number:";
>             $guess=<STDIN>;
>             chomp $guess;
>  if ($guess>$im_thinking_of) {
>              print "You guessed too high!\n";
>               } elsif ($guess < $im_thinking_of) {
>               print "You guessed too low!\n";
>               } else {
>               print "You got it right!\n";
> }
>
>  I'm trying to make that ^^^  not end if you guess the number wrong.  The
chapter im reading is using the "for" and "while" loop, but i guess I dont
know enough yet to do this.  Can someone help?
>
>
> ---------------------------------
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to