Re: Simple loop question

2006-05-31 Thread Lawrence Statton
> > Get in the habit of using strict and warnings -- 'use warnings' is > > subtly different from 'perl -w' and you should start good habits > > early. Upgrade if you are using an ancient version of Perl that does > > not come with warnings. > > > So would it be a conflict to use both "-w" and "st

Re: Simple loop question

2006-05-31 Thread John W. Krahn
Danny wrote: > Hi list, Hello, > Hope this is not too simple or a stupid question: > > I have a slight problem with a loop. It is a simple numbers guessing game. It > works fine, but when I run this script, it gives me "Too low" immediately > after > the prompt. What should I do to get the last

Re: Simple loop question

2006-05-31 Thread Mr. Shawn H. Corey
On Wed, 2006-31-05 at 20:03 +0200, Danny wrote: > > Get in the habit of using strict and warnings -- 'use warnings' is > > subtly different from 'perl -w' and you should start good habits > > early. Upgrade if you are using an ancient version of Perl that does > > not come with warnings. > > > So

Re: Simple loop question

2006-05-31 Thread Danny
> > > > #!/usr/bin/perl > > use strict; > > use warnings; > > > > our ($upper, $lower, $target) = ( 20, 1, 11 ); > > > > D'oh! I really _meant_ to make those lexical instead of package > variables - another good habit to get in early. > > my ($upper, $lower, $target) = (20,1,11); > Will do (p

Re: Simple loop question

2006-05-31 Thread Danny
> Here's one way to accomplish what you want, and it eliminates some of > the redundancy. BTW, get used to using strict. It really does help in > the long run and it's better to learn it early than to decide to go back > later and fix your old programs. > I am making it a habbit now. Thank you v

Re: Simple loop question

2006-05-31 Thread Danny
> Get in the habit of using strict and warnings -- 'use warnings' is > subtly different from 'perl -w' and you should start good habits > early. Upgrade if you are using an ancient version of Perl that does > not come with warnings. > So would it be a conflict to use both "-w" and "strict"? Dann

Re: Simple loop question [SOLVED]

2006-05-31 Thread Danny
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 ..." p

Re: Simple loop question

2006-05-31 Thread Lawrence Statton
> > #!/usr/bin/perl > use strict; > use warnings; > > our ($upper, $lower, $target) = ( 20, 1, 11 ); > D'oh! I really _meant_ to make those lexical instead of package variables - another good habit to get in early. my ($upper, $lower, $target) = (20,1,11); -- To unsubscribe, e-mail: [EMAIL

Re: Simple loop question

2006-05-31 Thread Lawrence Statton
> Hi list, > > Hope this is not too simple or a stupid question: > > I have a slight problem with a loop. It is a simple numbers guessing game. It > works fine, but when I run this script, it gives me "Too low" immediately aft > er > the prompt. What should I do to get the last "else" statement d

Re: Simple loop question

2006-05-31 Thread Mr. Shawn H. Corey
On Wed, 2006-31-05 at 17:58 +0200, Danny wrote: > Hi list, > > Hope this is not too simple or a stupid question: > > I have a slight problem with a loop. It is a simple numbers guessing game. It > works fine, but when I run this script, it gives me "Too low" immediately > after > the prompt. Wha

RE: Simple loop question

2006-05-31 Thread Timothy Johnson
Here's one way to accomplish what you want, and it eliminates some of the redundancy. BTW, get used to using strict. It really does help in the long run and it's better to learn it early than to decide to go back later and fix your old programs. ### #!/usr/bin/p