my %foo_cache; sub foo { $foo_cache{join ",", @_} ||= do { ... rest of sub goes here } } #### my %foo_cache; sub foo { @{$foo_cache{join ",", @_} ||= [ do { ... rest of sub goes here }]} } #### my %foo_cache; sub foo { return @$_[0..$#$_] for $foo_cache{join ",", @_} ||= [ do { ... rest of sub goes here }] }