Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^2: Interview Prepration

by merlyn (Sage)
on Apr 04, 2005 at 07:17 UTC ( #444595=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://444595]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2021-06-14 13:21 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (62 votes). Check out past polls.