So I needed to access the symbol table of one of my modules, recently. After a few hours on the web (and after wracking my brain for a bit) I came up with the following:
sub getSymbolTable (\T, $cu-name) is export {
return Nil unless $cu-name;
my $nodes = $cu-name.split('::').Array;
my $fn = $nodes.shift;
my $st = T.WHO{$fn};
return Nil if $st.WHO === Nil;
for $nodes[] {
$st = $st.WHO{$_};
return Nil if $st.WHO === Nil;
}
$st.WHO;
}
So if you have a package called A::B::C, then getSymbolTable(MY, "A::B::C")
will extract its Stash for you.
Enjoy!