Re: resetting foreach loops and @lists

2001-12-21 Thread Shawn
Hey Curtis, > Your "Incorrect" statement is puzzling. Sure, that code is incorrect, but it's not what I posted. Yes, you are correct, the two examples that I gave were not what you posted. That is why I posted yours above mine with the indents. You asked me for an example. I was giving you on

RE: resetting foreach loops and @lists

2001-12-21 Thread Curtis Poe
--- Bob Showalter <[EMAIL PROTECTED]> wrote: > > With the '=>' (a.k.a. 'fat comma'), the left side of the operator > > does no (sic) need to be quoted IF IT DOES NOT CONTAIN WHITESPACE. > > Actually, it needs to be quoted if it doesn't look like an identifier, > (with an optional leading

RE: resetting foreach loops and @lists

2001-12-21 Thread Bob Showalter
> -Original Message- > From: Curtis Poe [mailto:[EMAIL PROTECTED]] > Sent: Friday, December 21, 2001 2:25 PM > To: Shawn; [EMAIL PROTECTED] > Subject: Re: resetting foreach loops and @lists > > ... > With the '=>' (a.k.a. 'fat comma'), t

Re: resetting foreach loops and @lists

2001-12-21 Thread Curtis Poe
--- Shawn <[EMAIL PROTECTED]> wrote: > > > #!/usr/bin/perl -w > > use strict; > > my %test_hash = ( > > one => 'no problem', > > two => 'still no problem' > > ); > > print $test_hash{ one }; # prints 'no problem' (without quotes) > > #!/usr/bin/perl -w >

Re: resetting foreach loops and @lists

2001-12-21 Thread Shawn
> #!/usr/bin/perl -w > use strict; > my %test_hash = ( > one => 'no problem', > two => 'still no problem' > ); > print $test_hash{ one }; # prints 'no problem' (without quotes) #!/usr/bin/perl -w use strict; my %test_hash = ( my one => 'no problem',

Re: resetting foreach loops and @lists

2001-12-21 Thread Curtis Poe
--- Shawn <[EMAIL PROTECTED]> wrote: > > > Bare words as hash keys. > > > > And that's a problem how? > > It's a big problem when using 'strict'... Shawn, Could you give an example of that? #!/usr/bin/perl -w use strict; my %test_hash = ( one => 'no problem',

RE: resetting foreach loops and @lists

2001-12-21 Thread Bob Showalter
> -Original Message- > From: Shawn [mailto:[EMAIL PROTECTED]] > Sent: Friday, December 21, 2001 11:45 AM > To: Bob Showalter; 'John W. Krahn'; [EMAIL PROTECTED] > Subject: Re: resetting foreach loops and @lists > > > > > > -Original Mes

Re: resetting foreach loops and @lists

2001-12-21 Thread Shawn
> strict won't have a problem with bareword hash keys unless they have spaces > and maybe some special characters. If your hash keys are always single > words strict won't complain. > > Rob Hmmm, well, I have always gotten runtime errors with it. I guess I use a lot of spaces in my hashes... ne

RE: resetting foreach loops and @lists

2001-12-21 Thread Hanson, Robert
AM To: Bob Showalter; 'John W. Krahn'; [EMAIL PROTECTED] Subject: Re: resetting foreach loops and @lists > > -Original Message- > > From: John W. Krahn [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, December 20, 2001 6:10 PM > > To: [EMAIL PROTECTED]

Re: resetting foreach loops and @lists

2001-12-21 Thread Shawn
> > -Original Message- > > From: John W. Krahn [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, December 20, 2001 6:10 PM > > To: [EMAIL PROTECTED] > > Subject: Re: resetting foreach loops and @lists > > > > > > James Lum wrote: > &

RE: resetting foreach loops and @lists

2001-12-21 Thread Bob Showalter
> -Original Message- > From: John W. Krahn [mailto:[EMAIL PROTECTED]] > Sent: Thursday, December 20, 2001 6:10 PM > To: [EMAIL PROTECTED] > Subject: Re: resetting foreach loops and @lists > > > James Lum wrote: > ... > > la

Re: resetting foreach loops and @lists

2001-12-21 Thread Andrea Holstein
James Lum wrote: > ... > a sample of my code looks like: > > foreach $zrec (@file) # file with agent and city > { chomp($zrec); >foreach $zkey (@template) # put agent city data into hash >{ $hash{$zkey},$zrec)=split(/\//,$zrec,2); >} >foreach $zrec2 (@list)

Re: resetting foreach loops and @lists

2001-12-20 Thread John W. Krahn
"John W. Krahn" wrote: > > Try this example to see if it does what you want: > > #!/usr/bin/perl -w > use strict; > > my $count; > START: > for my $var ( 1 .. 4 ) { > print "$var "; > last if ++$count > 20; > goto START if $_ == 3; This line _should_ be: goto START if $var =

Re: resetting foreach loops and @lists

2001-12-20 Thread Michael Fowler
On Thu, Dec 20, 2001 at 05:00:46PM -0500, Hanson, Robert wrote: > If you use "redo" while in that loop it will reset it and start over Just a bit of clarification: redo will not cause the loop to reset and start over. redo causes the current loop block to execute again, without re-evaluating the

Re: resetting foreach loops and @lists

2001-12-20 Thread John W. Krahn
James Lum wrote: > > how do i reset a foreach loop so that it starts at the top each time? > > a sample of my code looks like: > > foreach $zrec (@file) # file with agent and city > { chomp($zrec); >foreach $zkey (@template) # put agent city data into hash >{ $hash{$z

RE: resetting foreach loops and @lists

2001-12-20 Thread Hanson, Robert
A foreach loop will always start at the first element and run to the last element. If you use "redo" while in that loop it will reset it and start over, and if you use last it will drop out of the loop. You only ever need to restart a loop if you are already in it. Maybe you could offer some s