in reply to Re: Nested Dispatch Tables?
in thread Nested Dispatch Tables?

That sort of sounds like what I'm looking for. In the end, I want to be able to make a call like $actions->{$type}->{$action}->();, or however you'd accomplish the same thing(if that makes any sense) in actually valid Perl.

This isn't the most elegant of solutions, but would building my two dispatch tables(something like %objects and %containers) and then storing them into an %actions hash as references work?

Replies are listed 'Best First'.
Re^3: Nested Dispatch Tables?
by dirving (Friar) on Mar 24, 2008 at 19:23 UTC
    The code you give there is valid Perl. If you built a structure using something like the following you would be able to use it just like that:
    my $actions = { first_action => { type1 => \&some_function, another_type => \&another_function }, second_action => { another_type => \&function, yet_another_type => \&something, }, };
    -- David Irving
Re^3: Nested Dispatch Tables?
by jfraire (Beadle) on Mar 25, 2008 at 01:26 UTC

    Altough you have said that you are not using object-oriented techniques, what chromatic gave you reads like this: $container->action() or $object->action() which looks quite elegant to me. Instead of dispatch tables, you would have two classes and then choose what kind of object to create depending on your $type variable. Then, for each class, you would have your special $actions (methods). That way your main code is the same for both containers and objects, and their differences are hidden in their own space.

    Julio