in reply to Re: Selective module loading
in thread Selective module loading

Is this the part you are referring to? (From XML::SAX)
sub add_parser { my $class = shift; my ($parser_module) = @_; if (!$known_parsers) { $class->load_parsers(); } # first load module, then query features, then push onto known_par +sers, my $parser_file = $parser_module; $parser_file =~ s/::/\//g; $parser_file .= ".pm"; require $parser_file; my @features = $parser_module->supported_features(); my $new = { Name => $parser_module }; foreach my $feature (@features) { $new->{Features}{$feature} = 1; } # If exists in list already, move to end. my $done = 0; my $pos = undef; for (my $i = 0; $i < @$known_parsers; $i++) { my $p = $known_parsers->[$i]; if ($p->{Name} eq $parser_module) { $pos = $i; } } if (defined $pos) { splice(@$known_parsers, $pos, 1); push @$known_parsers, $new; $done++; } # Otherwise (not in list), add at end of list. if (!$done) { push @$known_parsers, $new; } return $class; }

Seems similiar, but I'm still not sure how that affects methods and such called after the require. Although after looking at perlmod a bit more, I think I may be alright with the existing code. As the problems seem to stem when you depend on exported (well... imported really) things due to the BEGIN blocks that normally come into play, which I can get around by specifying the namespace. ...I think :)