Questions tagged [hash-of-hashes]

A hash-of-hashes is a multi-dimensional hash that contains nested hashes.

A multi-dimensional hash is a flexible, nested structure where hash values are allowed to be other hashes. This data structure is natively supported by languages such as:

  • Perl
  • Python
  • Ruby

and may be simulated by others.

141 questions
1
vote
1 answer

Inserting element in an array of array in perl

Suppose i have a hash as below: my @A=( 1,2,[[ 1,2 ],[ 3,4,5 ]], [ 6,7,8 ]); How do i insert an array in the third element of the array above? Third element here is an array of arrays and i want to insert an array [9,10]. how can do this?
user1939168
  • 547
  • 5
  • 20
1
vote
1 answer

list-of-list vs. hash-of-hashes

Setup: I need to store feature vectors associated with string-string pairs. The string-string pairs encode an input-output relationship. There will be a relatively small number of inputs X (e.g. 5), and for each input x, there will be a relatively…
1
vote
1 answer

Sorting by value Hash of Hashes Perl

Let's say I have a hash of hashes data structure constructed as followed: %HoH => ( flintstones => { family_members => "fred;wilma;pebbles;dino", number_of_members => 4, }, jetsons => { …
cooldood3490
  • 2,418
  • 7
  • 51
  • 66
1
vote
0 answers

Implementing music wishlist like hash of hashes

I'm trying to work with itunes rails gem, for example: >> itunes = ITunes::Client.new >> songs = itunes.music('green day she') => <#Hashie::Rash result_count=15 results=[...]> so I need to make a wishlist with tracks founded with itunes gem and…
xamenrax
  • 1,724
  • 3
  • 27
  • 47
1
vote
1 answer

not able to access hash of hash of array values

I have written the following code in Perl. The code is reading a pdb file and getting some values. Ignore the top part of the code,where everything is working perfect. Problem is in the sub-routine part, where I try to store arrays in the hash3 with…
dissw.geek9
  • 245
  • 1
  • 6
  • 11
1
vote
1 answer

perl fork vs. thread for shared data structures

I am writing a script where I need to share data structures among multiple processes. Currently I am forking, which worked great when I only needed to share simple variables (i.e. $var, @arr, %hash). However more recently I've been trying to share…
srchulo
  • 5,143
  • 4
  • 43
  • 72
0
votes
2 answers

Replicate Rails I18n.t method

Using rails we rely on I18n.t and maybe more things that are configured in YAML files should be used with a similar method. For example, I have a file with icecream prices icecreams: water: strawberry: 5 watermelon: 5 peach: 6 …
Lomefin
  • 1,173
  • 12
  • 43
0
votes
2 answers

Perl: Combining the values of two arrays of hashes and making the values of the second array the keys of the output hash

Sorry if what I'm calling array of hashes is something else. I'll just refer to these things as 'structures' from now on. Anyways, Let's say I have two structures: my @arrayhash; push(@arrayhash, {'1234567891234' => 'A1'}); push(@arrayhash,…
You Idjit
  • 31
  • 4
0
votes
2 answers

symbolizing and replacing a value in hash values in hash of array of hash

I have a data structure which is something similar to this lib_data = {'library'=>[{"type"=>"Books", "checkout"=>false, "data"=>[{"type"=>"Books", "operator"=>"AND", "details"=>{"property"=>"Name", "author"=>"%s", "name"=>"%s"}},…
nova_rubo
  • 49
  • 1
  • 7
0
votes
3 answers

Merging hashes with values having the same key getting appended

I wanted to know what would be the best way to achieve this: my_hash_1 = { fruits: { red: 'apple' }, vegetables: { green: 'spinach' } } my_hash_2 = { fruits: { green: 'grapes' } } expected_output = { fruits: { red: 'apple', green: 'grapes' },…
0
votes
3 answers

How to map ruby hashes correctly based on key provided

My data is like: h = { themes_data: { Marketing: [ { id: 68, projectno: "15", } ], Produktentwicklung: [ { id: 68, projectno: "15", }, { …
LearningROR
  • 211
  • 1
  • 13
0
votes
3 answers

How can I iterate through nested hash of hash without knowing its key?

I have a hash of hashes, that is, hash and hash references in my data structure. Can I iterate through the deepest hash when I only have the main hash name and no key of the deepest hash? my %gates_info=( 'order' => { 'nand' => { …
P_Z
  • 199
  • 2
  • 8
0
votes
2 answers

Remove duplicate keys from a hash of hashes and arrays (and ensure any resulting empty hashs are also removed)

I have a data stream in JSON format that my script accesses from an internal website. My script converts the JSON to a perl hash using JSON.pm (I'm using perl 5.10.1 on RHEL 6.9) Within this hash are multiple nested hashes, and nested arrays, some…
Speeddymon
  • 496
  • 2
  • 20
0
votes
1 answer

Printing out multiple hash values from an array

Hi I am trying to push out multiple hash values within a function. I can only get the first hash to return. I would like to get all hash values to return so that I can format them after I can pull out the data but so far I am only able to get the…
user6378390
0
votes
2 answers

Print the hash name of a hash of hashes of hashes etc

So I have a massive hash of hashes. $VAR1 = { 'Peti Bar' => { 'Mathematics' => 82, 'Art' => 99, 'Literature' => 88 }, 'Foo…
Ben
  • 749
  • 1
  • 7
  • 18