Created
August 4, 2011 14:39
-
-
Save karupanerura/1125305 to your computer and use it in GitHub Desktop.
get_all_isa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub get_all_isa($) { ## no critic | |
_get_all_isa(shift, +{}); | |
} | |
sub _get_all_isa { | |
my($class, $searched_hash) = @_; | |
my @class_isa = do { | |
no strict 'refs'; | |
grep { not exists $searched_hash->{$_} } @{"${class}::ISA"}; | |
}; | |
foreach my $isa (@class_isa) { | |
next if(exists $searched_hash->{$isa}); | |
_get_all_isa($isa, $searched_hash); | |
$searched_hash->{$isa} = 1; | |
} | |
keys %$searched_hash; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment