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

Re^2: scoping inside the loop

by Anonymous Monk
on May 17, 2013 at 18:36 UTC ( #1034006=note: print w/replies, xml ) Need Help??

in reply to Re: scoping inside the loop
in thread scoping inside the loop

Thanks LanX.Understood but in second case which is a working condition $i's scope is in outer loop but how it got tucked in to inside loop.My understanding is if my is before a variable it's existence is strictly with in that boundary. In case 2 my is associated with $i so i think it only resides outside or where it is defined but i am confused how it got transported to loop.

Replies are listed 'Best First'.
Re^3: scoping inside the loop
by LanX (Bishop) on May 17, 2013 at 18:40 UTC
    No, up to the point that you declare an inner $i with my the outer one is used.

    No inner my $i means the outer one is everywhere available.

    These are universal rules for lexical variables in almost any language!

    Have a look at the scoping-article I linked.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1034006]
[marto]: /mefails
[thezip]: Duh... I found it. Idempotentcy
[thezip]: howdy marto!

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2018-07-18 20:41 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (395 votes). Check out past polls.