Compiling my own modules?
I developed my own module (package) for example MyUtils.pm
. It is a file located in the same folder as the one that main.cgi
uses it. Then I use the module withuse MyModule;
I think this is a little slow. Or suppose there is a better way. Is it possible to "compile a module" and include it in perl core or something?
If so, I think it will load and run "faster".
source to share
Don't worry too much about it. The overhead of loading a Perl module is pretty low.
If your application is getting enough traffic that this overhead becomes significant, the time to stop using CGI - the overhead of running the Perl interpreter becomes a problem on its own. Try converting your site to use something like FastCGI ( CGI::Fast
or Plack::Handler::FCGI
), or mod_perl Apache module (possibly combined with ModPerl::Registry
to run CGI scripts or with directly Plack::Handler::Apache2
). Any of them will allow processing several consecutive requests by one process, completely bypassing the module loading process.
source to share
I think you are looking for B :: Bytecode .
DESCRIPTION
Compiles a Perl script to bytecode format, which can be loaded later by the ByteLoader module and executed like a regular Perl script. This saves time for selecting and compiling options, as well as for in-memory source code.
source to share