On Fri, 27 Feb 2009, Justin Wyllie wrote: > I want to instantiate an object just once in the lifetime > of a script, not on every request. I'm used to Mason > where you can use Mason's <%once> block. In mod_perl > proper would the equivalent be to instantiate it in a > BEGIN block? But it would need to be in scope for the > whole script..
You are using straight CGI, or using ModPerl::Registry? If using registry, you should be able to instantiate the object just by putting it in package scope (anywhere.) Same is true for a proper handler. If using straight CGI, you probably can't do this, because the interpreter gets started up fresh for every hit to the url. Mark