http://qs321.pair.com?node_id=16270

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

I'm attempting to create a module which loads a Perl module by name. So a database has a list of modules by a more friendly name, and a script calls the loader function to load the actual module and return an object. Example of what I'm trying to do: sub load($module) { if ($nett_load_hash$module == 0) { use vars qw($module); $nett_load_hash$module = 1; } return $module->new(); } Obviously, it doesn't work at the 'return' part. How would I do this? PHP works nicely by loading "modules" ($module = new $name). Anything like this in Perl?

Originally posted as a Categorized Question.