in reply to Dispatch table within package question
Make sure that when you call the methods like this (i.e. $message_types{$type}->()) that you take into account that $self won't automatically be part of @_ as if you had called it like $self->method(). You have to explicitly pass it in your dispatcher methodsub sub { my ($self,$type,@args) = @_; my %message_types = ( type1 => $self->can("type1"), type2 => $self->can("type2") ); return $message_types{$type}->($self,@args); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Dispatch table within package question
by chromatic (Archbishop) on Jan 26, 2005 at 21:53 UTC | |
by bpphillips (Friar) on Jan 27, 2005 at 13:33 UTC |