in reply to Hashes of Arrays of Hashes (sometimes of Arrays)

Encapsulate. You've got complex data structures. Your code is going to be complex. You should consider hiding some of that complexity behind an Object-Oriented interface. Create a module to represent your upper level %hash, and then write accessors to get at the various pieces. For example:
package OBJ; sub new { shift; bless {@_}, 'OBJ'; } sub normal { shift->{normal} } sub listl { my $self = shift; my $index = shift; my $key = shift; $self->{listl}[$index]{$key}; } ##### package main; my $obj = new OBJ(normal => "some text", listl => [{keys => vals}, {keys => vals}, ]); $normal = $obj->normal(); $value = $obj->listl(0,'key');
Do note that this is a very bare bones example, with no error checking, no way to set new values for the object's various components, etc.

--DrWhy

"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Replies are listed 'Best First'.
Re^2: Hashes of Arrays of Hashes (sometimes of Arrays)
by Bro. Doug (Monk) on Aug 12, 2006 at 00:37 UTC
    Yes. I quite like the idea, thank you. But how can I assign the refs to -textvariable in Tk? I'm thinking:
    #in the package declaration sub getref { my ($self,$index,$key) = @_ ; #and then, erm.... return \$self->{'list'}[$index]{$key} ; } #and in the Tk block: $widgets{'foo'} = $obj->getref( 0, 'bar') ;

    That would probably work, but then I need to push a copy of the object onto a list of said object. The problem becomes essentially a Tk problem. The -textvariable option points to scalar refs that are, in turn, encapsulated by the object I build to hold the code. Bleh.
    Bro. Doug The Inert.