From: Jesse Luehrs Date: Mon, 28 Nov 2011 22:40:50 +0000 (-0600) Subject: hack in support for package::anon specifically here X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d621315953ba8906c2a5346de654298e5c70959b;p=gitmo%2FPackage-Stash.git hack in support for package::anon specifically here would be nice to do this more generically, but can't figure out how for now --- diff --git a/lib/Package/Stash/PP.pm b/lib/Package/Stash/PP.pm index f60ac4a..98b86b8 100644 --- a/lib/Package/Stash/PP.pm +++ b/lib/Package/Stash/PP.pm @@ -243,8 +243,17 @@ sub get_symbol { } else { if ($type eq 'CODE') { - no strict 'refs'; - return \&{ $self->name . '::' . $name }; + # XXX we should really be able to support arbitrary anonymous + # stashes here... (not just via Package::Anon) + if (blessed($namespace) && $namespace->isa('Package::Anon')) { + # ->can will call gv_init for us + $namespace->bless(\(my $foo))->can($name); + return *{ $namespace->{$name} }{CODE}; + } + else { + no strict 'refs'; + return \&{ $self->name . '::' . $name }; + } } else { return undef;