http://www.perlmonks.org?node_id=514787


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.