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 :)
In reply to Re^4: A perl buffer
by betterworld
in thread A perl buffer
by leonidlm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |