Thank you all for the input on how to resolve to problem with the second loop.

Alex
On 12/11/2012 5:00 PM, Shawn H Corey wrote:
On Tue, 11 Dec 2012 16:47:15 -0500
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";

     $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'.

You have to eat, er, clear the first cookie. :)




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to