Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Getting Module Names Dynamically and using it

by broquaint (Abbot)
on Dec 07, 2005 at 10:36 UTC ( #514787=note: print w/replies, xml ) Need Help??

in reply to Getting Module Names Dynamically and using it

If you already have the filenames then just use them in conjunction with require e.g
require $_ for @modules;
Then you can execute the class methods like so:
my @tables = map $_->table_name, @module_names;


Replies are listed 'Best First'.
Re^2: Getting Module Names Dynamically and using it
by xdg (Monsignor) on Dec 07, 2005 at 11:17 UTC

    I don't think the latter part of that will work -- the OP said that the list is of filenames, e.g. "lib/Foo/Bar/", not package names, e.g. "Foo::Bar::Baz". And if the list were of package names, they would need to be converted to filenames to be used with require in the way you suggest, or instead be called in an eval:

    # if @modules contains package names, not filenames eval "require $_" for @modules;

    The OP might want to look at Module::Require or UNIVERSAL::Require and see if either would be applicable/helpful for this situation.


    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://514787]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (1)
As of 2022-08-16 01:58 GMT
Find Nodes?
    Voting Booth?

    No recent polls found