in reply to Doubly-nested deeply bound variable is undefined

Could it be related to this?

Unlike dynamic variables created by the local operator, lexical variables declared with my are totally hidden from the outside world, including any called subroutines. This is true if it's the same subroutine called from itself or elsewhere--every call gets its own copy.
(From perlsub).

emc

At that time [1909] the chief engineer was almost always the chief test pilot as well. That had the fortunate result of eliminating poor engineering early in aviation.

—Igor Sikorsky, reported in AOPA Pilot magazine February 2003.
  • Comment on Re: Doubly-nested deeply bound variable is undefined

Replies are listed 'Best First'.
Re^2: Doubly-nested deeply bound variable is undefined
by asokoloski (Sexton) on Nov 14, 2006 at 18:49 UTC
    I don't think that's it. I'm pretty sure that's talking about variables declared within the subroutine.

    Right after the part you mentioned, perlsub says this:

    This doesn't mean that a my variable declared in a statically enclosing lexical scope would be invisible. Only dynamic scopes are cut off. For example, the bumpx() function below has access to the lexical $x variable because both the my and the sub occurred at the same scope, presumably file scope.
    my $x = 10; sub bumpx { $x++ }
    I thought that since the lexical scope of $x includes the body of bumpx(), any closures created inside bumpx should also have access to $x -- and they do, kinda. But it seems like bumpx() (or foo(), in my case) has to be "reminded" that $x is in its scope, otherwise the inner sub doesn't get access.