> So, if I wanted global object that would only ever be initialized once,
> would I need to do something like run it from a startup script  with
> PerlRequire, rather than within a handler module?

You can do this in many ways.  You can put it in a global, and always access
it from there.  You can make a singleton object that will hold it and return
it whenever you ask (TemplateSingleton->get_instance() or something).

> Is there any benefit to doing this
> with a Template object and sharing it among handler modules, or is it
> better to have one per module?

You should have just a single Template object (per mod_perl process), so
that all templates use the same cache.

Jay pointed out that since your "our $template" declaration is not inside of
your handler sub, it will only be run when your module is being compiled the
first time.  That means you are effectively doing the right thing already
for that one module, but if you intend to call that object from other
modules you should share it using one of the ways I mentioned above.

- Perrin



Reply via email to