On Wed, Dec 12, 2012 at 12:16 PM, Andy Bach wrote:
> I used a temp var as you had ("$cookie"), but in this case, using the
> default while usage assings directly to $_:
> while ( <> ) {
> if ( $_ eq 'cookie') {
>
"assigns directly to $_"
> and that gets easier with regular expressio
On Tue, Dec 11, 2012 at 3:47 PM, Alex Ahn wrote:
> I have a problem with a certain script, as a beginner.
>
#!/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') {
On Tue, Dec 11, 2012 at 9:41 PM, Alex Ahn 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 promp
Before your 2nd while loop, add:
$cookie = "";
> 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 = );
> }
>
> print "Mmmm. Cookie.\n";
>
> whil
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 wrote:
I have a problem with a certain script, as a beginner.
#!/usr/bin/perl -w
#
# Cookie Monster
$cookie = "";
whi
Hi,
On Tue, Dec 11, 2012 at 10:47 PM, Alex Ahn 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 = );
> }
>
> print "Mmmm. Cookie.\n";
>
On Tue, 11 Dec 2012 16:47:15 -0500
Alex Ahn 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 = );
> }
>
> print "Mmmm. Cookie.\n";
>
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 = );
}
print "Mmmm. Cookie.\n";
while ( $cookie ne 'cookie') {
print 'Give me another cookie: ';
chomp($cookie =