{ my %memo; sub rec_func { my $key=key_from_input(@_); unless (exists $memo{$key}) { $memo{$key}=calculate(@_); } return $memo{key}; } }