Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
more useful options
 
PerlMonks  

Re: why need my in a foreach loop?

by PeterPeiGuo (Hermit)
on Nov 28, 2010 at 06:09 UTC ( #874072=note: print w/ replies, xml ) Need Help??


in reply to why need my in a foreach loop?

Why not? What's the benefit of not requiring this? What's the benefit of not having consistent rule here?

Peter (Guo) Pei


Comment on Re: why need my in a foreach loop?
Re^2: why need my in a foreach loop?
by ikegami (Pope) on Nov 28, 2010 at 08:22 UTC
    The OP points out that there's no real difference between for $lex (...) and for my $lex (...). The "my" is just useless noise. As such, the declaration could be implicit.

    It's reasonable, but it's not true because foreach loops don't just work with lexicals.

      The foreach loop always works with an alias. IMHO the variable is never connected to anything outside the for loop so the values never "leak" out of the loop. If I am mistaken, please give an example when that variable is connected to something else as well.
        I've already showed when it makes a difference.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2014-04-16 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (433 votes), past polls