in reply to Re^3: A perl buffer
in thread A perl buffer

I knew that someone would find this loophole ;)

Well, it would not exactly "fail", it would just ignore the cache. Perl 5.10 has help for us:

my $result = $cache{$input} //= function($input);

Of course, there might still be the case where the function returns undef or a list or depends on the context. Before conjuring up a perfect solution that honours all special cases, I'd better let you use Memoize as recommended above :)

Replies are listed 'Best First'.
Re^5: A perl buffer
by gaal (Parson) on Aug 10, 2008 at 20:47 UTC
    You can use exists. Of course, you still have to know the context you're being called in...