Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Packaging multiple use statements into a module

by djerius (Beadle)
on Feb 08, 2010 at 21:14 UTC ( #822086=perlquestion: print w/replies, xml ) Need Help??
djerius has asked for the wisdom of the Perl Monks concerning the following question:

I have several modules which perform the same long set of use statements. For example:
use A; use B; use C;

I'd like to create a module (say ABC) which essentially performs the above use statements but runs the modules' import() routines in the module from which ABC is use'd. The latter part is the grotty part I'd like to avoid having to write (without it there's not much point in the whole exercise).

I'm pretty sure that there's a module on CPAN which handles this sort of thing and makes it effortless. I think I saw something closely related to this in the daily CPAN modules list a few months ago, but I can't find it.

Any help is appreciated.

Thanks, Diab

Replies are listed 'Best First'.
Re: Packaging multiple use statements into a module
by Fletch (Chancellor) on Feb 08, 2010 at 21:28 UTC

    Perhaps you're thinking of Toolkit? (No experience with it or opinion one way or the other, just actually remembered the name of it :)

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      There are two problems with Toolkit that I see. First is that it uses a source filter to do its work, and that is almost guaranteed to become a problem eventually. Second is that it is meant to load one set of modules that are defined per-machine.

      I think ToolSet is generally a better choice. In addition to not using source filters, it is meant to build your own modules for including groups of prerequisites. Being based on modules like this instead of a single per-machine list makes it redistributable as well.

        After looking at ToolKit I've come to the same conclusions that you have. Thanks for pointing out ToolSet — it's much more along the lines of what I want. And it has the added benefit that I think I understand what it's doing!
      Yes! That's exactly the one. Thanks a lot.
Re: Packaging multiple use statements into a module
by ikegami (Pope) on Feb 08, 2010 at 21:37 UTC
    If you're using Exporter, you can use its export_to_level
      From my reading of Exporter's documentation, this would require modifications to the modules' import() routines. If a module didn't have its own import(), one could inject one into its namespace, but if it has its own one would have to tread more carefully. And, as you point out, this works only for modules which use Exporter.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://822086]
Approved by toolic
Front-paged by Arunbear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2017-02-27 07:43 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (376 votes). Check out past polls.