This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix-ups for Attribute::Handlers
authorFather Chrysostomos <sprout@cpan.org>
Sat, 6 Sep 2014 20:09:05 +0000 (13:09 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 15 Sep 2014 13:19:32 +0000 (06:19 -0700)
It was making unreliable assumptions about the contents of stashes.

dist/Attribute-Handlers/lib/Attribute/Handlers.pm

index 4ae65d9..a0b4af9 100644 (file)
@@ -13,12 +13,16 @@ sub findsym {
        return $symcache{$pkg,$ref} if $symcache{$pkg,$ref};
        $type ||= ref($ref);
        no strict 'refs';
-        foreach my $sym ( values %{$pkg."::"} ) {
+       my $symtab = \%{$pkg."::"};
+       for ( keys %$symtab ) { for my $sym ( $$symtab{$_} ) {
+           if (ref $sym && $sym == $ref) {
+               return $symcache{$pkg,$ref} = \*{"$pkg:\:$_"};
+           }
            use strict;
            next unless ref ( \$sym ) eq 'GLOB';
             return $symcache{$pkg,$ref} = \$sym
                if *{$sym}{$type} && *{$sym}{$type} == $ref;
-       }
+       }}
 }
 
 my %validtype = (