in reply to Re: Re: Re: Re: How do I make one package use a module from another package?
in thread How do I make one package use a module from another package?

Importing into your module means that function names that are defined nowhere in your code are suddenly significant. This is sort of OK and sometimes convenient, but only if done directly, IMO, by which I mean you use Some::Module and it exports functions into your space that you can lookup by saying perldoc Some::Module.

But if Some::Module imports from 4 other modules, then exports to your space, it gets harder to track down what's happening, espcially if one of those 4 other modules does the same.

Using an OO implemntation, where the module's methods are only aavailble via an object call (my $o = Some:Object->new(); my $result = $o->do_it_all_now(@parms)) means that you are far less likely to have name collision amongst the subs in your various modules because they're tracked down by the object. Then, if the modules you're calling needed to be broken down to work, they use and inherit from other modules, rather than imporutng and exporting (in general) for the same reasons.

It's cleaner, and that gets more important when more programs - and especially when more programmers - are involved.

There are lots of writeups that will do a much better job than I've just done of explaining this - I hope I've given some flavor of this.

--Bob Niederman, http://bob-n.com
  • Comment on Re: Re: Re: Re: Re: How do I make one package use a module from another package?
  • Download Code