On Sat, Oct 06, 2007 at 11:25:25AM +0100, Andy Armstrong wrote:
>>
>>> But I like neither the name nor the interface. How about this:
>>>
>>> package BigApp::Report;
>>> use subclass qw(..::Utils Create Publish);
>>> # loads BigApp::Utils, BigApp::Report::Create,
>>> BigApp::Report::Publish
>>
>> "subclass" would imply more OO semantic than I'd like, as the module just
>> loads others modules, but I agree it's a better name than "relative" and I
>> can't find a better one.
>> Also agreeing for the API change. I know I was pondering about using ".."
>> but can't remember why I didn't.
>
> Would it also do
>
> use relative [to => 'My::Big::Namespace'] => qw( This That Munger::Fast
> Munger::Precise );
>
What's wrong about this?
eval "use My::Big::Namespace::$_;"
for qw( This That Munger::Fast Munger::Precise );
die $@ if $@;
Which you can wrap in a BEGIN block if you really want the loading to
happen at compile time...
And of course, you can tone it down to a single eval "", if you don't
like those:
BEGIN {
my $code = join '',
map {"use My::Big::Namespace::$_;"}
qw( This That Munger::Fast Munger::Precise );
eval $code;
die $@ if $@;
}
And I bet this works with 5.000. ;-)
--
Philippe Bruhat (BooK)
Trust only in incompetence. You will never be disappointed.
(Moral from Groo The Wanderer #16 (Epic))