damog has asked for the wisdom of the Perl Monks concerning the following question:
without having to declare SomeClass, SomeOtherClass and all other classes in there. Basically all those classes are on a directory (but I could use some other modules too) so I tried this:# myscript.pl use SuperModuleLoader; # or whatever my $c1 = SomeClass->new; my $c2 = SomeOtherClass->new; my $mech = WWW::Mechanize->new;
...but that doesn't work. Is that possible? As said, SomeClass.pm, SomeOtherClass.pm and other custom classes are right on the same directory, but some other might just be within the system-wide installation and wanna be able to initialize classes with them on my script without having to list them all in it.package SuperModuleLoader; sub import { my $classes = [qw/SomeClass SomeOtherClass WWW::Mechanize YourMom/]; for my $c (@$classes) { require $c; } } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: On kind of dynamic loading
by Corion (Patriarch) on Sep 25, 2010 at 08:12 UTC | |
|
Re: On kind of dynamic loading
by Anonymous Monk on Sep 24, 2010 at 19:15 UTC |