--- James Edward Gray II <[EMAIL PROTECTED]> wrote:
> Let's start with the easy one, __END__. There's no > magic going on > here, you're program will run fine without it. > Consider it a note to > perl that reads, "My code stops here, don't read > on." I add it to > programs I post into messages like this, so you > and/or perl, can tell > where the code I posted ends. Ok, that makes sense. > PRIMES: ... is a label. I'm labeling the first > loop, so I can make my > call to next() push that loop along, instead of the > one I'm currently > in. By default, next() works on the immediately > enclosing loop. > This makes sense. > > > The reason I didn't use the default variable, is > because we're talking > about nested foreach loops here. If they both stuck > their values in > the same place, the inside loop would clobber the > outside loops values > and I would have no way to access both. > Ah, so there is a use for the for which is like foreach other than a shortcut. Can I do that with foreach? I see that what you are describing with the foreach loops above is what was going on with my nested foreach loops before. > > next() jumps to the next iteration of the target > loop, or the enclosing > loop, by default. Consider this example: > > foreach (1..10) { > next if $_ % 2; # skip to the next number, if this > one is odd > print "$_\n"; # this prints just even numbers > } > That is helpful. Though why would you want to use next? Is is just another way to do something? > Hope that clears up the rest of your confusions. > Yup, for the most part. Thanks. > James > __________________________________ Do you Yahoo!? Yahoo! Search - Find what you’re looking for faster http://search.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>