in reply to Difference between foreach and grep

A lot more context would be useful here. I think they don't have much in common, actually, besides that they both loop over a list. I think grep has more in common with map than foreach.

Replies are listed 'Best First'.
Re^2: Difference between foreach and grep
by velusamy (Monk) on Dec 06, 2008 at 04:42 UTC
    Dear Monk, Comparing "grep" and "foreach" which one is efficient for looping?

      As said before by many others perhaps you could describe a scenario which explains what you want to achieve, with maybe a short example then it would be easier to help you ...
      A bad example: You could also ask: which is the best editor? (For what? hmm uh?)
      Posting on PerlMonks
      But it breaks down simple to this imho:
      If asking questions its best to read it again and try to imagine the point of view from a possible helper:

      Does my question contain all that is needed to answer it from the "other side"
      without knowing what i know (and maybe forgot to write down), imagine people dont know what your current problem does look like -they also dont know your level of experience- they only see what you write, which information you provide ...

      If you are unsure if your question is too detailed (which doesnt seem to be your general problem ;-) you could provide:

      Here is a short explanation: " ... " (Try to give a quick overview, for the impatient reader).After that you could go in more detailed: Here are more details regarding my problem " ... " Maybe with "Read more" tags ...

      hth MH

      Well that depends on the reason for looping. We still need more information.

      I'm so adjective, I verb nouns!

      chomp; # nom nom nom