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
0
votes
2 answers

How do I iterate through an array of hashes of arrays once per hash, and not once per nested array element?

Apologies if this has been resolved elsewhere. I searched and searched. I'm working with a config file that separates chunks of data by left-aligning the name of each chunk and indenting arguments for each name (see __DATA__ below). I've written a…
kyoob
  • 499
  • 5
  • 23
0
votes
2 answers

How can I most efficiently iterate over a hash of hashes in order based on key value in inner hash?

I've got a JSON hash of hashes returned by a website API that I want to parse and display based on a specific key's value within the internal hashes. I can think of solutions that would achieve this, but they would take a number of lines of code and…
Dan
  • 3,246
  • 1
  • 32
  • 52
0
votes
2 answers

calculating the sum of specific array values in ruby?

Pivotal Tracker is a project management tool that I use. I'm using the Pivotal Tracker Ruby Gem to access the API. I'm trying to create a hash of each member with the number of points that they have assigned to them. The end result should look…
tonic
  • 453
  • 1
  • 6
  • 21
0
votes
2 answers

Iterating over Perl hash of hashes and array of hashes

I'm stuck yet again and need some assistance. As usual, it's my nemesis - Hashes. Essentially, I'm trying to write to a database, all the items of software on a z/OS mainframe. I have managed to progress to the following hash: $VAR1 = { …
0
votes
2 answers

Perl add Hash to Hash of Hashes at the end

I am trying to add hash to my hash of hashes like this: %funkce = ( "funkce1" => { "file" => "soubor1", "name" => "jmeno1", "varargs" => "args", "rettype" => "navrat", "params" => [ "typ", …
Libor Zapletal
  • 13,752
  • 20
  • 95
  • 182
-1
votes
1 answer

Easiest way to grab "target" key from the hash shown

This is the output of Dumper for the hashref in question: #!/usr/bin/perl use Data::Dumper; sub getUpgradeTaskUUIDS { my $derp = SF::Transaction::Update::getUpgradeTasks(); print "Derp is:\n"; print Dumper $derp; [... do stuff…
-1
votes
2 answers

Adding a hash that has an array in Ruby and adding to that array

Hello all I'm new and I've been searching and can't find a clear answer to this question, I'm hoping this summarizes it: a = {:a1 => "a1", :b1 => [] } how would I add :c1 to the a hash and make it another hash, leading to an array, and add values…
-1
votes
1 answer

How do we sort a multi dimensional hash based on the value?

I have an hash which looks like this when I use dumper: { hello => { pqr => { a => 455, b => 52, c => "hello" }, lmn => { a => 3, b => 39, c => "hi" } }, hi => { suv => { a =>…
Sai Kiran
  • 145
  • 1
  • 2
  • 5
-1
votes
2 answers

How to find the depth of a nested hash of hashes?

I am trying to write a Perl subroutine to process any given hash (passed by reference) but I would like to make it a generic one so that I can use it anywhere. Assuming the hash has simple key/value pairs and is not an elaborated record (containing…
User9102d82
  • 1,172
  • 9
  • 19
-1
votes
1 answer

Ruby hash of array

I have a list of Flights departing and arriving to an airport. Each Flight has a departure/arrival time. I want to display the list of flights as a timeline with the departures on the left and arrivals on the right, grouped by hours, like this: …
H Mihail
  • 613
  • 8
  • 18
-1
votes
1 answer

Return single :key from nested hash in ruby

From psd.rb gem by LayerVault, I get a hash that contains all the layers and groups of the psd in nested hashes. Here is a gist of the hash. I want to retrieve a certain key from that hash. Is there a way to do this and store those keys values in an…
Sam Mason
  • 1,037
  • 1
  • 8
  • 29
-1
votes
1 answer

Confusion with checking Hash of Hash of Arrays

I am trying to compare my hash input to valid allowed options in my data structure, and if it's not one of the options then I set the default value for the key. I seem to be missing something here though. Example of current data structure.. my $opts…
hwnd
  • 69,796
  • 4
  • 95
  • 132
-1
votes
3 answers

Iterate through hashed hashes in ruby

I am a beginner and am looking for a method to iterate through a hash containing hashed values. E.g. I only want to print a list of all values of inner hash-elements of the key named "label". My array is looking like this: ary =…
-1
votes
1 answer

Reverse hash of hashes in Perl

I got this output by decoding JSON data. Now I want to reverse this data structure and print it using Perl. Can anyone can help me with the code snippet below? I have this data in one variable and I printed it. My output is as shown below I have a…
ravikiran
  • 105
  • 1
  • 1
  • 7
-1
votes
1 answer

Perl hash of hashes

I have a file with a list of lines like at 12345 injected value 1 to 'signal_A' at 12345 injected value 0 to 'signal_B' at 12346 injected value 1 to 'signal_A' at 12348 injected value 1 to 'signal_A' at 12350 injected value 0 to 'signal_A' at…
giri_lp
  • 9
  • 1
1 2 3
9
10