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

Finding current package name from XS

Thread Next
From:
Felipe Gasper
Date:
June 21, 2020 23:31
Subject:
Finding current package name from XS
Message ID:
7B042757-5260-4BF8-92FE-F58713E8BB8D@felipegasper.com
Hello,

	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()'
main
-----

	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!

-Felipe
Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About