Nicole Seitz wrote: > > hi there! Hello,
> I've got a problem with a complex data structure and hope you can help me. > > I know that I can't have a hash whose values are arrays. So I tried to > build a hash of references to arrays. > > I guess I've made some mistakes . > > This is what my hash looks like: > > %myHash = (); > # lots of code here > $myHash{"245"} = [[$len245oa,$pos,$tag245oa]]; ^^ ^^ This is a Hash of Arrays of Arrays. In other words, that is equivalent to: $myHash{245}[0][0] = $len245oa; $myHash{245}[0][1] = $pos; $myHash{245}[0][2] = $tag245oa; > #some code here > > $myHash{"856"} = [[$len856_41,$pos,$tag856_41]]; ^^ ^^ Same here. > #some code here > #now I have to add a new element(which is also an array) to the outer > anonymous array > #Is the following correct? > $myHash{"856"}[1] = [$len856_42,$pos,$tag856_42]; > > #Then I'd like to iterate over the array of sorted hash keys(no problem) > > @sortedKeys = sort keys %myHash; ^^^^ Are you _sure_ you need to sort the keys? > foreach $key (@sortedKeys) { > # now I have to change the value of each second element of the inner > arrays($myHash{$key} [$index][1] ???) > #Unfortunately, I don't know how to do this. I guess, first, I need > another loop.But then how to access the second element and overwrite it??? foreach my $key ( sort keys %myHash ) { # now I have to change the value of each second element of the inner foreach my $item ( @{$myHash{$key}} ) { $item->[1] = 'something'; } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]