in reply to how to create shared hashes of arrays

I would try doing it in a sample script first. without threads.. to make sure you are constructing the Data struct correctly.

Firstly, your concept of an HoA is a little off. The hash doesn't contain an array.. the hash keys.. hash to array references as their value. for example:
my $test = [1,2,3,4]; my %test = (array => $test); print $test{array}
this should print something like
ARRAY(0x2251e4)
So to print an element of that array you would do
print $test{array}->[0];
Take a look at Perl Data Structures Cookbook @ perldoc.com

Replies are listed 'Best First'.
Re^2: how to create shared hashes of arrays
by sumit_nagpal (Initiate) on Jul 09, 2004 at 13:19 UTC
    i think i know that its the array reference which is stored in the as the value... i dont think i m facing any problems in that... its only the shared hash which is giving problems...
      got it!!! i was trying a few things and this one worked... $my_hash{$key} = &share([]); push(@{$my_hash{$key}},@{$arr_ref}); --Sumit
      From what I've read the shared hash should be almost no different.. so long as your constructing it correctly.. and what not.. post some sample code so we can see what's going on.
        yes there is difference we can not assign it a reference unless we share that hash location for hash of array $hash{$key} = &share([]) (my case) then we can do ---> $hash{$key} = $arr_ref; for hash of hash $hash{$key} = &share({}) then we can do ----> $hash{$key}{next_key} = "xxx"; Thanks Sumit