in reply to Re: Re: Caching process sets
in thread Caching process sets
This code would check if an action correponding to $key is known, determine the action if it's not known, and in either case execute the action:
The sub determine_action would have to find out what the correct action is, and return a sub reference to it. If you don't want to make explicit subs, use anonymous ones:($actions{$key} ||= determine_action($key))->($key, $data);
sub determine_action { my ($key) = @_ if (it's first action) { return sub { my ($key, $data) = @_; do stuff; }; elsif (it's second action) { return sub { my ($key, $data) = @_; do stuff; }; ... etc... }
|
|---|