hack in support for package::anon specifically here
Jesse Luehrs [Mon, 28 Nov 2011 22:40:50 +0000 (16:40 -0600)]
would be nice to do this more generically, but can't figure out how for
now

lib/Package/Stash/PP.pm

index f60ac4a..98b86b8 100644 (file)
@@ -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;