my @to_check = ("::"); while (my $pkg = pop @to_check) { next if $pkg eq "::main::"; # because ::main:: and :: are the same foreach my $sub_pkg (grep /::$/, keys %{$pkg}) { my $full_pkg = "$pkg$sub_pkg"; print "checking $full_pkg\n"; print "$full_pkg inherits\n" if check_isa($full_pkg); push(@to_check, $full_pkg); } }