develooper Front page | perl.perl5.porters | Postings from June 2020

Finding current package name from XS

Thread Next
Felipe Gasper
June 21, 2020 23:31
Finding current package name from XS
Message ID:

	I’m finding that PL_curstash gives "main" in one-liners even from a different package, e.g.:

perl -MMy::XSModule -e'package Foo; print My::XSModule::current_package_name()'

	A bit later I found that what does work is:

HvNAME( (HV*)CopSTASH(PL_curcop) )

	Is CopSTASH part of the API? perl5160delta says that its _flags variant is explicitly not part of the API, but I don’t see mention of CopSTASH itself. If CopSTASH is not part of the API, is there something else I can use to parse PL_curcop?

	Thank you!

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About