Hi, On Tue, Dec 11, 2012 at 10:47 PM, Alex Ahn <nisnamanar...@gmail.com> wrote:
> I have a problem with a certain script, as a beginner. > > #!/usr/bin/perl -w > # > # Cookie Monster > > $cookie = ""; > > while ( $cookie ne 'cookie') { > print 'Give me a cookie: '; > chomp($cookie = <STDIN>); > } > > print "Mmmm. Cookie.\n"; > *** HERE -- Attention Please *** The variable $cookie still has the value 'cookie'. So to enter the second while loop, like Shawn rightly pointed out --- clear the variable $cookie like so: $cookie = ""; > > while ( $cookie ne 'cookie') { > print 'Give me another cookie: '; > chomp($cookie = <STDIN>); > } > > print "Mmmm. Cookies.\n"; > > When I input 'cookie', the script will print the lines that will appear > from the first and second requests. The script will not print the second > request's demand. I think it's because the ne value is the same for the > two, and I cannot separate the demands unless I change the ne value for the > second demand to 'another cookie'. > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- Tim