I am running a web app under plackup with starman and trying to dynamically load and instantiate packages based on user requests. I am using 'require $packageName;' to load the package where $packageName contains the name of the package, the names are stored in a config file. I then execute a known set of commands on the instance as all classes inherit from a base class and contain a set of known methods.
This works fine under Apache, but for some reason plackup is saying it cannot locate the package even though @INC contains the library path and the package names are absolute from the last directory in the lib path. That is, the package name would be Base::My::Package.
Anyone experience this issue? Do I need to update some other path within Starman? I am executing plackup with the -I flag as well as updating my environment PERL5LIB variable. I also tried 'use lib /...'
in the main app class, but none of these work.
Thanks
require
will only accept module names (e.g. Scalar::Util) when they're specified as barewords. If you giverequire
a string, then it needs to be a relative path to the module (e.g. Scalar/Util.pm). You can get around this by doing therequire
inside aneval
(the string-parameter form ofeval
), e.g.eval "require $package"
.See Check the list of module installed in machine