Surely another way of ensuring that a scalar is readonly and therefore
sharable is to either use the constant pragma or readonly
pragma. But then you won't be able to make calls that alter the
variable even a little, like in the example that I've just showe,
because it will be a true constant variable and you will get compile
time error if you try this:

You can use the PerlRequire and PerlModule directives to load
commonly used modules such as CGI.pm, DBI and etc., when the
server is started. On most systems, server children will be able to
share the code space used by these modules. Just add the following
directives into httpd.conf:

PerlModule CGI
PerlModule DBI

But an even better approach is to create a separate startup file
(where you code in plain perl) and put there things like:

use DBI ();
use Carp ();

Don't forget to prevent importing of the symbols exported by default
by the module you are going to preload, by placing empty parentheses
() after a module's name. Unless you need some of these in the
startup file, which is unlikely. This will save you a few more memory
bits.

Then you require() this startup file in httpd.conf with the
PerlRequire directive, placing it before the rest of the mod_perl
configuration directives:

PerlRequire /path/to/start-up.pl

CGI.pm is a special case. Ordinarily CGI.pm autoloads most of
its functions on an as-needed basis. This speeds up the loading time
by deferring the compilation phase. When you use mod_perl, FastCGI or
another system that uses a persistent Perl interpreter, you will want
to precompile the functions at initialization time. To accomplish
this, call the package function compile() like this:

use CGI ();
CGI->compile(':all');

The arguments to compile() are a list of method names or sets, and
are identical to those accepted by the use() and import()
operators. Note that in most cases you will want to replace ':all'
with the tag names that you actually use in your code, since generally
you only use a subset of them.