Re: Cookies - Basic Perl

2012-12-13 Thread Andy Bach
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

Re: Cookies - Basic Perl

2012-12-12 Thread Andy Bach
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') {

Re: Cookies - Basic Perl

2012-12-12 Thread Andy Bach
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

Re: Cookies - Basic Perl

2012-12-12 Thread Nathan Hilterbrand
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

Re: Cookies - Basic Perl

2012-12-11 Thread Alex Ahn
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

Re: Cookies - Basic Perl

2012-12-11 Thread timothy adigun
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"; >

Re: Cookies - Basic Perl

2012-12-11 Thread Shawn H Corey
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"; >

Cookies - Basic Perl

2012-12-11 Thread Alex Ahn
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 =