sub isa { my $obj = shift; my $base = ref($obj) || $obj; my $class = shift; my %is_seen; my @pkgs = ("UNIVERSAL", $base); no strict 'refs'; while (scalar @pkgs) { my $pkg = pop @pkgs; return 1 if ($pkg eq $class); # Found it! next if exists $is_seen{$pkg}; # Already processed this one ++$is_seen{$pkg}; # Mark this package seen push @pkgs, @{"${pkg}::ISA"}; # Append what this inherits from } # Searched the inheritance tree, failed to find it, so... return 0; }