"R. Joseph Newton" wrote:
> Sorry, the function I proposed [see bottom] did not properly enclose the
> declaration, and thus would not have provided the protection I referred to.. Should
> have been:
> test_cache();
> sub test_cache {
> my $cache = {};
>
> &test("hello0",$cache);
> &test(
"Shishir K. Singh" wrote:
> Try using it like this
>
> -
Hi Shishir,
There is just one problem here, as demonstrated below, with the addition of a
"brick-tosser" function.
use strict;
my $cache = {};
&test("hello0",$cache); # Note: better written as tes
Rob Anderson wrote:
>
> I'm trying cache a function to help speed it up.
Have a look at the Memoize module at CPAN.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Rob Anderson wrote:
> Thanks but I don't see how this could work. I've tried using it, but to no
> avail
Hi Rob
I can't think what could be wrong if you've copied Janek's code. I've written
a simple subroutine with a persistent hash which simply counts the different
strings it's called with and d
he->{$cache_key} = $param . "done"; # save the value
print "does not exists\n";
}
--
-Original Message-
From: Rob Anderson [mailto:[EMAIL PROTECTED]
Sent: Friday, March 28, 2003 10:36 AM
To: [EMAIL PROTECTED]
Subject: Re: Variable scoping, static variable
Thanks but I don't s
Thanks but I don't see how this could work. I've tried using it, but to no
avail
"Janek Schleicher" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Rob Anderson wrote at Fri, 28 Mar 2003 14:45:07 +:
>
> > -- module sub routine
> >
> > sub test {
> > my $param =
Rob Anderson wrote at Fri, 28 Mar 2003 14:45:07 +:
> -- module sub routine
>
> sub test {
> my $param = shift;
> my $cache_key = "param=$param";
> if (exists $cache{$cache_key}) {
> return $cache{$cache_key};
> }
> sleep 1;
> $cache{$cache_key} = $