in reply to Doubly-nested deeply bound variable is undefined

My closure fu is not strong, but my guess is that the $x that is assigned the string is not the same instance of $x that is passed to the annon sub in the run_this call. If you change the my to our you will get the behaviour you expect.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Doubly-nested deeply bound variable is undefined
by asokoloski (Sexton) on Nov 14, 2006 at 18:54 UTC
    Sounds right. I just don't understand why a print() statement makes perl change its mind and use the correct instance of $x. Actually, I've been playing around with it and it seems like any reference to $x inside foo() makes it work correctly, even if it's just $x; on a line by itself.