Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Getting Module Names Dynamically and using it

by broquaint (Abbot)
on Dec 07, 2005 at 10:36 UTC ( [id://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;
HTH

_________
broquaint

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/Baz.pm", 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.

    -xdg

    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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-18 02:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found