From 5f0fb29dc02d2ad322afbba1056af6a96256f907 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 21 Jul 2013 11:45:43 -0400 Subject: add a function to get the package of the currently compiling code --- Keyword.xs | 7 +++++++ lib/Parse/Keyword.pm | 1 + 2 files changed, 8 insertions(+) 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) { -- cgit v1.2.3-54-g00ecf