in reply to Re: Re: Caching process sets
in thread Caching process sets

It's still not entirely clear to me what you're doing, but it sounds like you want are (anonymous) sub references.

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:

($actions{$key} ||= determine_action($key))->($key, $data);
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:
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... }