How do I dynamically discover packages from a partial namespace in perl?
问题 I have a directory structure that looks like: Foo::Bar::Baz::1 Foo::Bar::Baz::2 etc Can I list the packages from something like: use Foo::Bar::Baz; Thanks! Edit: Made it more clear what the modules are. 回答1: Just to be clear, are you looking at random packages in random Perl code? Or for Perl modules , e.g. "a/b/c/d1.pm" with module "a::b::c::d1"? In either case, you can not use a single "use" statement to load them all. What you need to do is to find all the appropriate files, using either