in reply to Re^2: Dispatch table within package question
in thread Dispatch table within package question

Perl implements hashes such that lookups are extremely efficient. The size of the hash doesn't matter.

Your syntax,

$self->{message_types}->{$type}->(@args);

should be fine. What's the error? What's your code? Remember, that won't use the current value of $self, but the one $self had when the anonymous sub was created (assuming $self was a lexical (my) variable).

Replies are listed 'Best First'.
Re^4: Dispatch table within package question
by loris (Hermit) on Oct 14, 2005 at 06:59 UTC

    Sorry, you're right, it does work as you say. I had tried it out in an existing module with a whole lot of other gubbins with seemed mess things up (or at least prevent me from seeing clearly what I was doing).

    Thanks again for the help.

    loris


    "It took Loris ten minutes to eat a satsuma . . . twenty minutes to get from one end of his branch to the other . . . and an hour to scratch his bottom. But Slow Loris didn't care. He had a secret . . ."