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
--- 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
> -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
--- 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
>
> #!/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',
--- 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',
> -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
> 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
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]
> > -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:
> &
> -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
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)
"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 =
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
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
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
16 matches
Mail list logo