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


in reply to Re: Interview Prepration
in thread Interview Prepration

for & foreach are now an alias to each other
Uh, no. You might want to read what I wrote about Perl's "contractions", and my specific comments on "for" vs "foreach".

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^3: Interview Prepration
by cog (Parson) on Apr 04, 2005 at 09:05 UTC
    I know what you mean, you are correct, but you can write for or foreach and you will get the same result (and you say that in that link), which was what I was trying to say :-)

    It didn't even occured to me mentioning the two different types of for/foreach because I thought of the question in terms I answered it :-)

Re^3: Interview Prepration
by Anonymous Monk on Apr 04, 2005 at 07:43 UTC
    Uh, yes. The words for & foreach are an alias to each other.
      Right. They're syntax aliases, but they're semantically entirely different things. Did you read what I quoted? It explains what I mean, and I don't want to keep retyping that.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        To quote:

        They're definitely two different kinds of loops. However the text for and foreach may be used to introduce either one. The actual loop-style is determined by what follows.
        Which, seems to me, answers the question:
        What is the difference between for & foreach, exec & system
        as "for & foreach are aliases - there is no difference. They both introduce either a for-style loop or a foreach-style loop, determined by what follows."

        Methinks you're getting a bit bent out of shape over someone agreeing with you. Either that, or I'm completely missing your point.