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

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.
  • Comment on Re: Re^6 (Third Time): mod_perl and cache?

Replies are listed 'Best First'.
Re^8: mod_perl and cache?
by Aristotle (Chancellor) on Mar 04, 2003 at 08:35 UTC
    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.
Re: Re: Re^6 (Third Time): mod_perl and cache?
by Flame (Deacon) on Mar 03, 2003 at 22:17 UTC
    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.
        Hmm, I just did a little test... I'm running v5.8.0 and this yielded "Tie::IxHash" and "HASH" and "".
        use Tie::IxHash; use strict; use warnings; { my %hash; print ref(tie(%hash, "Tie::IxHash"))."\n"; $hash{'hi'} = 1; $hash{'there'} = 2; some(\%hash); } sub some{ my $temp = shift; print ref($temp)."\n"; my %hash = %{$temp}; print ref(tied(%hash)); }




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

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