in reply to Using an "outer" lexical in a sub?
For additional reading, I recommend perlsub, namely "Private Variables via my()".my $outer = 1; # lexical file scope { my $inner = 1; # here I can see both $inner and $outer # as $outer is "inherited" from the outer # lexical scope { my $inner = 2; # this $inner is completely different $inner # than the $inner in the direct outer scope # but still I can see $outer } # now I can see $inner that is equal to 1 } # now I can see only $outer
|
|---|