in reply to Pure perl lexical sub import

Another approach may be to manipulate the Scratchpad of the scope calling import().

I've never tried to use PadWalker in conjunction with lexical subs, but it might be worth a try.

NB: since PadWalker isn't core this wouldn't qualify as "pure Perl" anymore.

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Pure perl lexical sub import
by NERDVANA (Priest) on Dec 22, 2024 at 20:10 UTC
    I was hoping for some magic trick using perl syntax, like aliasing the lexical function in a 'for' loop while localizing it, or maybe something involving an attribute that would trigger MODIFY_CODE_ATTRIBUTES and then use experimental ref assignment to overwrite the CV that the ref is pointing to, or something.

    If PadWalker was core that would be one thing, but an XS module would be even further out of the question for avoiding dependencies.

Re^2: Pure perl lexical sub import
by LanX (Saint) on Dec 21, 2024 at 18:20 UTC
    I did some experiments and I doubt PadWalker can be of help here :/

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery