http://qs321.pair.com?node_id=444751


in reply to Re^4: Interview Prepration
in thread Interview Prepration

If you can show me a single instance in which the use of "for" instead of "foreach" makes a difference in code, I'll believe you.

Replies are listed 'Best First'.
Re^6: Interview Prepration
by merlyn (Sage) on Apr 04, 2005 at 18:13 UTC
    Do you mean the word for exchanged for the word foreach? No. Those keywords are syntactically equivalent. And I don't disagree with that fact.

    Do you mean replace a for loop with a foreach loop, or vice versa? Certainly! They have different semantics!

    The keyword "for" is the same as the keyword "foreach". The "for" loop is different from the "foreach" loop. Do I need to keep repeating this? {sigh}

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

    A reply falls below the community's threshold of quality. You may see it by logging in.