You need a reference to $var, that's the only possibility.
PadWalker can only help here if you know at least one function using var from the outer scope( see closed_over() )
Sounds very fragile.
Theoretically you could dive into B and try
to localize $var from the OP tree but that's a maintenance nightmare.
If its your module just export our $varref=\$var
this doesn't confuse the ref count and is the cleanest approach.
Update: and if you love source filter hacking you could require manually, that is find the module, read the text, append the above line and eval all.
Interesting discussion, though that was most likely an XY Problem... :)
HTH
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
PS: I even doubt you can retrieve the ref of a var using B , but I'd love to know. |