The most straightforward approach would be require or Module::Load or Module::Pluggable.
Module::Pluggable would automatically load all modules, while you need to load the modules when using require or Module::Load.
Module::Pluggable allows you to automatically instantiate objects when loading a plugin, and allows easy enumeration of loaded plugins, but for your case, I consider Module::Load or a simple require to be the clearer approach:
sub new_class { my $class = shift; (my $module = $class) =~ s!::!/!g; require "$module.pm"; $class->new( @_ ); } my $red = new_class('redObjects', color => 'red'); my $green = new_class('greenObjects', color => 'green');
In reply to Re: Passing package/module names to script as argument
by Corion
in thread Passing package/module names to script as argument
by Amblikai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |