in reply to Re: Re^4 (Third Time): mod_perl and cache?
in thread mod_perl and cache?

Would I need to do the same with %session and $DBH, not to mention the Apache::Request object and the other "globals"?



My code doesn't have bugs, it just develops random features.

Flame ~ Lead Programmer: GMS (DOWN) | GMS (DOWN)

Replies are listed 'Best First'.
Re: Re^6 (Third Time): mod_perl and cache?
by perrin (Chancellor) on Mar 03, 2003 at 20:24 UTC
    Yes. You should not refer to any lexical variables defined outside the scope of the current sub. Try to code your subs so they are portable enough to be moved to a separate module without changing their code.
      Or he could just our them, I assume?

      Makeshifts last the longest.

        Yes, he could use "our" or "use vars" (which I still prefer), but then he'd have to make sure he explicitly reset them at the beginning of every request. Also, passing variables to subs through globals is just not a good practice in general.
      Hmm, Apache::Session works with a tied hash, how could I pass that without loosing the tie? (I did search through perltie, but I didn't find anything.)



      My code doesn't have bugs, it just develops random features.

      Flame ~ Lead Programmer: GMS (DOWN) | GMS (DOWN)

        Just pass a reference to it.