Without using a source-filter, is there a way to change the current running package? I'm trying to accomplish the same thing oose.pm does, and I'm wondering if I can drop my users in a non-main package.
I think you'll be able to do that by changing PL_curstash
and PL_curstname
on the C level.
PL_curstash = gv_stashpvs("Some::Package", GV_ADD);
sv_setpvs(PL_curstname, "Some::Package");
PL_curstash
is the stash of the current package during compilation, PL_curstname
is its name.
Update:
I've found this problem kind of interesting and implemented the solution as Devel::ChangePackage
. Turns out what I initially suggested just works. You can get it either from http://github.com/rafl/devel-changepackage, or from a CPAN mirror near you once they have updated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With