Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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;
HTH

_________
broquaint


Comment on Re: Getting Module Names Dynamically and using it
Select or Download Code
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
Node Status?
node history
Node Type: note [id://514787]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-08-28 03:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (255 votes), past polls