jammin has asked for the wisdom of the Perl Monks concerning the following question:

Hi Guys,

Can you remind me how to use all modules in a package?

I thought it was just use Package::*; but that doesn't seem to work.

Thanks

Replies are listed 'Best First'.
Re: use all modules in a package
by Joost (Canon) on Apr 28, 2005 at 12:03 UTC
    There is no built-in support for this kind of thing. If you typically need this functionality for some package, the package should provide you with it (but I guess some don't).

    For example, use Template loads the basic modules in the Template::Toolkit distribution.

    If the module you're using doesn't provide something like this, you'll have to write it yourself, and you have to specify all the modules explicitly.

      ok great thanks I'll write one.
Re: use all modules in a package
by blazar (Canon) on Apr 28, 2005 at 12:07 UTC
    Can you remind me how to use all modules in a package?
    It all depends on what "all modules in a package" are. I think "all packages in a module" makes more sense...
    I thought it was just use Package::*; but that doesn't seem to work.
    Why should it? What made you think it would? It's up to Package to provide such functionality. If really needed.

    Update: Said this, I can imagine some trickery to "load all modules from Some::Package onwards" (or "downwards"), but I'm not even sure if it can be done reliably and I strongly recommend not to even think of anything like that!

Re: use all modules in a package
by Roy Johnson (Monsignor) on Apr 28, 2005 at 14:45 UTC
    You may be thinking of export tags that let you say things like
    use Benchmark ':all'
    Probably not what you're looking for in this case, but that depends on what you are really trying to do.

    Caution: Contents may have been coded under pressure.
Re: use all modules in a package
by dmorelli (Scribe) on Apr 28, 2005 at 15:43 UTC
    I'll throw my opinion in here that this is generally not a great idea. It can easily make the code more difficult to understand/maintain. And what happens when you need to specify an import list for one or more modules? I foresee only bad things.

    On a related note, I never use .* imports in Java and discourage co-workers from doing so. I wish they had never included it in the language.

    PS: My apologies for mentioning the J-word.