Skip to content

Instantly share code, notes, and snippets.

@karupanerura
Created August 4, 2011 14:39
Show Gist options
  • Save karupanerura/1125305 to your computer and use it in GitHub Desktop.
Save karupanerura/1125305 to your computer and use it in GitHub Desktop.
get_all_isa
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