in reply to Is it wise to dynamically load modules?

foreach $ext (@ext) { eval "require $ext" $args_ref=$ext->process($args_ref) }

The above is written. It works. And yet, it's difficult to maintain.

Well, that's a pretty simple loop, and it didn't take you many lines to describe what it does, and why. Yet you claim it's difficult to maintain, so I expect there's something else going on as well. Why is it difficult to maintain, and why do you think it's easier if you put the functionality in different programs, and chain them? You will still be chaining, and you still need to logic to determine what to chain, and in which order.

Abigail

Replies are listed 'Best First'.
Re: Re: Is it wise to dynamically load modules?
by kurt_kober (Chaplain) on Oct 14, 2003 at 17:45 UTC
    The difficulty of maintenance came from instances where a weakness in one link of the chain would lead to problems when I was developing a new link. So there were times when it became confusing to know exactly where a problem was occurring and how to fix it. Plus, changes to the process would sometimes mean changes to all links--of course this would be a problem whether I was chaining subs or separate scripts.

    Guess the main point of the question is whether requiring the modules on the fly was an accepted practice or something I should avoid. Since nobody has yet recoiled in horror, I think I'll stick with it.

    Thanks!

      Requiring modules on the fly is a common technique.

      Abigail