check_pkg("::"); sub check_pkg { my $pkg = shift; # ::main:: and :: are the same and we don't want an inifinite loop return if $pkg eq "::main::"; 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); check_pkg($full_pkg); } } sub check_isa { # check @{$pkg."::ISA"} to see if it inherits }