summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-07-21 11:45:43 -0400
committerJesse Luehrs <doy@tozt.net>2013-07-21 11:47:50 -0400
commit5f0fb29dc02d2ad322afbba1056af6a96256f907 (patch)
treec30fffa8a40960191f54a63c17a928be1c704055
parentb35d374f486c3dcb1b2ba8ed5909903a9b34fc5b (diff)
downloadparse-keyword-5f0fb29dc02d2ad322afbba1056af6a96256f907.tar.gz
parse-keyword-5f0fb29dc02d2ad322afbba1056af6a96256f907.zip
add a function to get the package of the currently compiling code
-rw-r--r--Keyword.xs7
-rw-r--r--lib/Parse/Keyword.pm1
2 files changed, 8 insertions, 0 deletions
diff --git a/Keyword.xs b/Keyword.xs
index 91478b1..4a094e4 100644
--- a/Keyword.xs
+++ b/Keyword.xs
@@ -130,3 +130,10 @@ lex_read(len = 1)
CODE:
PL_curcop = &PL_compiling;
lex_read_to(PL_parser->bufptr + len);
+
+SV *
+compiling_package()
+ CODE:
+ RETVAL = newSVhek(HvNAME_HEK(CopSTASH(&PL_compiling)));
+ OUTPUT:
+ RETVAL
diff --git a/lib/Parse/Keyword.pm b/lib/Parse/Keyword.pm
index b1ec347..c981071 100644
--- a/lib/Parse/Keyword.pm
+++ b/lib/Parse/Keyword.pm
@@ -31,6 +31,7 @@ sub import {
lex_read_space
lex_read
parse_block
+ compiling_package
);
for my $helper (@helpers) {