... to prevent a user from taking advantage of the lexicals $self and $key, I explicitly hid them.
But $self and $key are lexicals defined within the scope of the doit subroutine (in the example given in Re: Passing an anonymous block to a method.) and so could not possibly (without resort to something like PadWalker*) be accessed by any code defined in a block outside of doit such as the one used to create the subroutine reference in the example. Am I missing something?
* Actually, AFAIU PadWalker, the lexicals $self and $key of doit would still not be accessible via PadWalker because doit is not called from the anonymous subroutine, nor are those lexicals in scope at the time the anonymous code executes. Update: On second thought, those lexicals would be accessible because the anonymous subroutine is called from doit and the lexicals are in scope at the time of the call; further, they would be accessible even in the presence of masking lexicals however, experiment shows they would not be accessible in the presence of masking lexicals.
Update: Oops: All this mess was actually intended to be a reply to Re^3: Passing an anonymous block to a method..
In reply to Re^2: Passing an anonymous block to a method.
by AnomalousMonk
in thread Passing an anonymous block to a method.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |