use strict; use Memoize; use Memoize::Storable; my $filename = './memory.tmp'; tie my %cache => 'Memoize::Storable', $filename; memoize 'function', SCALAR_CACHE => [HASH => \%cache]; print function(1), "\n"; print function(1), "\n"; print function(1), "\n"; print function(2), "\n"; sub function { my $wtf = shift; print "I am the function\n"; return 'anything'; }