【发布时间】:2011-04-01 06:51:19
【问题描述】:
我在 Perl 中实现了一个相当复杂的数据结构。这已分为大约 20 个类。基本上,任何时候你想使用这些类之一,你都需要使用它们。
现在,如果有人想使用这种数据结构,他们需要做如下事情:
use Component::Root;
use Component::Foo;
use Component::Bar;
use Component::Baz;
use Component::Flib;
use Component::Zen;
use Component::Zen::Foo;
use Component::Zen::Bar;
use Component::Zen::Baz;
... # 15 more of these...
use Component::Last;
能够操纵它的所有部分。我怎样才能为用户编写一个模块,所以他们所要做的就是
use Component;
要导入所有其他模块吗?
在这种特殊情况下,模块都是类并且没有导出。
【问题讨论】: