I am creating a bigger application in Perl, and I am wondering whether something like class autoloading similar to php’s can be done in Perl?
I checked catching exceptions and $SIG{__DIE__} redefining etc., but this doesn’t seem to be solution because it will be stopped on first “cannot find method new via package”, and then to load every module I should again call the whole program.
One solution could be to maybe scan all files in my lib and give it to @INC at runtime, but I don’t know whether this is good solution — probably not.
Do anybody have a suggestion?
Well, you probably want to read up on the following:
None of those are quite the same as PHP’s approach though.
However, it really is best practice to list all “normal” dependencies. This makes it easier to build installers / deploy to CPAN etc. There are a bunch of other modules that deal with loading plugins, where you really don’t know what to load until runtime.
Is there some difficulty with figuring out your dependencies, or do you just want to avoid a bunch of “use” statements at the top of each file?