in reply to creating multiple views of a hash by reordering its key and values

Your problem seems well-suited to be treated with object-oriented techniques.

Hide your data structures into an object, and create methods to get the views you need. You could then implement methods that reorder your hash on the fly or, if memory is not an issue, implement a cache that avoid recalculation of the same hash when not needed -but that would bring you back to the cumbersome and tedious problem to create new hashes for each dimensional rework of the original dataset :-).

Let me know if I should go further and drop some quick-and-dirty code you can use as starter.

Ciao!
--bronto

# Another Perl edition of a song:
# The End, by The Beatles
END {
  $you->take($love) eq $you->made($love) ;
}

  • Comment on Re: creating multiple views of a hash by reordering its key and values

Replies are listed 'Best First'.
Re: Re: creating multiple views of a hash by reordering its key and values
by herveus (Prior) on Jul 02, 2002 at 17:08 UTC
    Howdy!

    This answer doesn't really speak to the core issue -- the data model. See my reply below for more on my point...

    yours,
    Michal