>>>>> "Dermot" == Dermot  <paik...@googlemail.com> writes:

Dermot> It' is perl, v5.6.2, on a modperl 1,

...

Dermot> I guess the question is: Will the declaration of our %cache within a
Dermot> function-orientated sub-routine render it always uninitialized?

I believe what you are seeing is that %cache is per-child, so it has
to compute it *once* for each child, not once for the server overall.

Also, I'd red-flag your assignment inside to the cache var as
well as the outside.  The whole point of the do { } block is to mention
the cache just once.  If you need an intermediate place to hold it,
declare it:

return $cache{$key} ||= do {
  my $result;
  ...
  .. complex code ..
  $result = $something;
  ..
  $result;
};

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to