in reply to reference to self function
Then you usemy $m = $self->{method}; $self->{funcs}{$m} = $self->can($m);
Why don't you do this check in the constructur, btw?if (my $code = $self->{funcs}{$self->{method}}) { $self->$code(@params); } else { die "..."; }
Note that this isn't equivalent to $self->{funcs}{$m} = sub { $self->$m(@_) }; You'd get in trouble with the closure solution if you ever decide to clone your object. Then you'd still be using your old object.
Hope this helps,
|
|---|