in reply to Accesing hash of unknown dimension

One way is a recursive function:

sub trav_hash { my $ref = shift; my $type = ref $ref; if( $type eq 'HASH' ) { trav_hash( $ref->{$_} ) for keys %$ref; } elsif ( $type eq 'ARRAY' ) { handle_array( $ref ); } else { die "something weird is in our structure!"; } } sub handle_array { my $arrayref = shift; # do whatever we want with the array here.... } trav_hash( \%data );

Replies are listed 'Best First'.
Re^2: Accesing hash of unknown dimension
by Otogi (Beadle) on Mar 20, 2006 at 22:28 UTC
    Thanks for the help, I need to read about references again. even the sub to create the structure can actually be used to access it if I store the keys in an array. I would be interested in seeing more solutions if they exist.