Skip to content

Instantly share code, notes, and snippets.

@mfollett
Created September 9, 2010 05:03
Show Gist options
  • Save mfollett/571400 to your computer and use it in GitHub Desktop.
Save mfollett/571400 to your computer and use it in GitHub Desktop.
{
my %cache = {};
sub long_running_thing { # imagine your own long running method here
my $x = shift;
return $cache{$x} if( exists $cache{$x} );
my $result;
# do some long running thing, generate result
return $result;
}
}
say long_running_thing(42);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment