On Tue, Dec 11, 2012 at 9:41 PM, Alex Ahn <[email protected]> wrote:
> Thank you all for the input on how to resolve to problem with the second
> loop.
Not sure if this is what you're working towards, but the problem of prompt
and response is always a design decision - when you are looking to make a
multiple prompt script - is the first one inside or out of the while loop?
Will the text always be the same? How do you plan to have the user exit?
So, something like:
#!/usr/bin/perl -w
#
# Cookie Monster
use strict;
print 'Give me a cookie (q to quit): ';
while ( my $cookie = <> ) {
chomp($cookie);
if ( $cookie eq 'cookie') {
print "Mmmm. Cookie.\n";
print 'Give me another cookie (q to quit): ';
}
else {
last if $cookie eq 'q';
print q(That's not a cookie, give me cookie (q to quit): );
}
}
You sort of have to pick your duplications - not necessarily the best
route, but one way, anyway
--
a
Andy Bach,
[email protected]
608 658-1890 cell
608 261-5738 wk