in reply to Re: Dispatch table within package question
in thread Dispatch table within package question
Presumably, the method which contains the definition of the dispatcher will be called frequently. Is there any performance related disadvantage to this for, say, the case that the dispatcher hash is very large?
And if I did want to define the dispatcher as a member in the constructor along the lines of:
my $self->{message_types} = ( type1 => sub { $self->sub_1(@_); }, type2 => sub { $self->sub_2(@_); }, );
what would the call the dispatcher look like?
I tried:
$self->{message_types}->{$type}->(@args);
but as what I am doing is beyond my understanding of Perl hairiness, I wasn't suprised to find that it doesn't work. What would the correct code look like?
Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Dispatch table within package question
by ikegami (Patriarch) on Oct 07, 2005 at 14:55 UTC | |
by loris (Hermit) on Oct 14, 2005 at 06:59 UTC |