http://www.perlmonks.org?node_id=17414


in reply to Re: How can I add all the numbers in an array with out doing a foreach loop?
in thread How can I add all the numbers in an array with out doing a foreach loop?

Your first answer is really a foreach loop. Remember that for and foreach are synonyms. Your second answer, however, is very slick! Nice.
  • Comment on RE: Answer: How can I add all the numbers in an array with out doing a foreach loop?

Replies are listed 'Best First'.
RE: RE: Answer: How can I add all the numbers in an array with out doing a foreach loop?
by KM (Priest) on Jun 09, 2000 at 23:45 UTC
    Hence me saying 'The loopish way..'. Actually, they are both loops. I believe internally join() still loops to actually join all the elements. It isn't a loop like a for or foreach.

    Cheers,
    KM

      Right, I was just pointing out that using 'for' doesn't answer the question of not using a 'foreach' loop. It looks kind of funny when the question stipulates that the person doesn't want to use something, and then you use it in your answer. Thats all.
        I gave two ways to do it. There is no way to do it without some sort of loop happening somewhere. It is also why I said that that is the loopish way. Sorry if I gave too much information for your taste. I see your answer.. oh wait.. you didn't have an answer.

        Cheers,
        KM