tUsing module

tUsing module

am 27.02.2009 23:09:49 von kropotkin

This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C99928.1B8C9770
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi

This is a beginner question.

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..

Thanks

Justin
------=_NextPart_000_0007_01C99928.1B8C9770
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable



charset=3Diso-8859-1">




Hi

 

This is a beginner =
question.

 

I want to instantiate an object just =
once in the=20
lifetime of a script, not on every request.

 

I'm used to Mason where you can use =
Mason's=20
<%once> block.

 

In mod_perl proper would the equivalent =
be to=20
instantiate it in a BEGIN block? But it would need to be in scope =
for  the=20
whole script..

 

Thanks

 

Justin


------=_NextPart_000_0007_01C99928.1B8C9770--

Re: tUsing module

am 02.03.2009 00:17:03 von Mark Hedges

This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.

--373334887-2023524697-1235949424=:23922
Content-Type: TEXT/PLAIN; charset=iso-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE


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. =A0 I'm used to Mason
> where you can use Mason's <%once> block. =A0 In mod_perl
> proper would the equivalent be to instantiate it in a
> BEGIN block? But it would need to be in scope for=A0 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
--373334887-2023524697-1235949424=:23922--