>  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?

you would need some type of a look to itterate through your code, that is
why you book uses "for" and "while" {well actually you dont with an ugly
'goto' }. Here is one way to write your code with a while and perl's "last"
function:

<~~~ cut
while(){
$im_thinking_of=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";
  last;
       }

}

<~~~paste
----- Original Message ----- 
From: "Mr.T Mr.X" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, June 15, 2003 1:17 AM
Subject: I need to make this not end


> #!/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