Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^6: Hard syntax error or disambiguable parsing?

by ack (Deacon)
on Jan 29, 2009 at 16:17 UTC ( [id://739952]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Hard syntax error or disambiguable parsing?
in thread Hard syntax error or disambiguable parsing?

AhHa! In my earlier comment on one of the other threads, I had forgotten that the loop variable is not only lexical and in-scope in the loop's block, but that it is also aliased to the iterator.

Thanks GrandFather. I learn so much (sometimes mulitiple times since I am frequently not a very memory-rich Pilgrim) from the Monestary.

I am curious, however. Since the loop variable is aliased to the iterator (or to the iterator's values?); how does that work when the iterator doesn't appear to have variables, but rather constants (as in the case this thread is addressing (i.e., the (0..5) iterator)? And what would happen if you tried to change the iterator loop variable within the loop block>

By way of an example of that last question:

foreach $i (0..5){ $i = 9; print "$i\n"; }

Actually I can answer that myself by trying it. No need to answer that part of the question; I don't want to abuse the Monks with things I can easily do my self.

But the question before that last one is still nagging me.

ack Albuquerque, NM

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-24 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found