in reply to HOA with array slice?

Something like this ought to work:

my( $color, $fruit ) = @{$hoa->{keytwo}}[$idx_color, $idx_fruit];

There's nothing wrong with your use of a HoA. It is true, however, that a lot of thought should go into selecting the construction of complex datastructures. The right layout makes all the difference in code complexity/simplicity.


Dave

Replies are listed 'Best First'.
Re^2: HOA with array slice?
by northwind (Hermit) on May 25, 2005 at 17:48 UTC

    There's nothing wrong with your use of a HoA. It is true, however, that a lot of thought should go into selecting the construction of complex datastructures. The right layout makes all the difference in code complexity/simplicity.

    This is even more true when you try creating an artificial neural network in pure perl...  :)  Except in NN's it is normally three, or more, levels deep (AoHoH, HoHoH, etc.) and the code to transverse such structures can get a little intresting.