in reply to mod_perl and forwarding legacy functions to a global object

Create an instance in an init handler and stash it in $r->notes. Write procedural wrappers which retrieve that instance and call the appropriate methods. That instance will only exist for the lifetime of the one request.

Addendum: This also has the advantage of allowing new code to access the already existent instance and call the methods directly as well (either by using an already existing request record or by using Apache->request->notes).

Update: Ooop, as is pointed out below I meant pnotes which lets you store an arbitrary perl value. That's what one gets after getting spoiled by HTML::Mason doing everything for you. :)

Replies are listed 'Best First'.
Re^2: mod_perl and forwarding legacy functions to a global object
by elusion (Curate) on Jun 25, 2004 at 18:15 UTC
    Beautiful. Thank you. Apache->request->notes only stores strings, but I was able to store a flag that let me know if I'd created an object for that instance.
      pnotes allows you to store a reference to a data structure.

      -derby