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

Extract values from multi-dimensional hash

I have the following dataset : $name $id $value ## A abc 2.1 A pqr 5.9 A xyz 5.6 B twg 2.5 B ysc 4.7 C faa 4.7 C bar 2.4 D foo 1.2 D kar 0.3 D tar …
harsh
  • 79
  • 1
  • 7
0
votes
1 answer

Mapping keys in hash - if, exists, map

I'm trying to compare the contents of a file with a Hash of hashes. For this I am using map, if and exists, though ineffectively yet. Basically, I want to know if columns 0 to 2 of the file exist in a hash. If so, then I want to find whether column…
Sos
  • 1,783
  • 2
  • 20
  • 46
0
votes
1 answer

How to append new values to hash in Perl

I have a hash of hashes where, at the last level, I want each value to be appended - not updated - if that value already exists. What would be the best way to do this? I was thinking about making the values as lists, but this is probably not the…
Sos
  • 1,783
  • 2
  • 20
  • 46
0
votes
2 answers

Referring to a chain of hash keys in a Perl hash of hashes

I have a hash of hashes storing data like so our %deviceSettings = ( BB => { EUTRA => { DL => { CPC => "NORM", PLCI => { CID => 88 }, ULCPc => "NORM" }, UL => { REFSig => { DSSHift => 2,…
JonFitt
  • 303
  • 2
  • 9
0
votes
1 answer

Hash of hash access

I have this perl code and I'm not able to figure out one thing. my %instr_enabled= (); foreach my $instr (@{$attrib->get_A_instructions()}) { %instr_enabled = ( $instr->{instr} => { enable => $instr->{enable}, …
0
votes
2 answers

extracting specific value from a multidimensional hash in ruby by key name

let's say i have a multidimensional hash, and in one of the subhashes i have a key=>value pair which i need to retrieve by key. how can i do it? example hashes: h={:x=>1,:y=>2,:z=>{:a=>{:k=>"needle"}}} h={:k=>"needle"} key is always :k, and i need…
Pavel K.
  • 6,697
  • 8
  • 49
  • 80
0
votes
1 answer

Trouble with Perl Data structures HoA breaking or HoH key not created

This is a question about Perl data structures, but first a breif description of some details involved. I have a perl script that uses DBI and performs three queries against a mysql database ($q1 $q2 $q3). Each query returns 2 or 3 fields (which is…
BryanK
  • 1,211
  • 4
  • 15
  • 33
0
votes
1 answer

Perl Hash of Hashes creation

I have a log file which looks like as follows. Year:2001 State: A District A District B State: B District A District B Year:2002 State: A District A District B State: B District A District B . . Year:2012 State: A District A District B State:…
deep
  • 686
  • 4
  • 17
  • 33
0
votes
2 answers

Printing elements stored in hash of a hash

final HashMap> teams; teams= new HashMap>(); teams.put(1,new HashMap(){{ put(2,new Integer[] { 1,0});}}); …
0
votes
3 answers

Get value from hash of hashes

I would like to get value from hash of hashes but i do not. My code is : sub test { my $filename = $_[0]; open INFILE, ${filename} or die $!; my %hashCount; my @firstline = split('\t',); shift(@firstline); while (my…
Tof
  • 301
  • 5
  • 17
0
votes
1 answer

How to compare the inner hash values of following HoH with those of the other list

my %main_hash = ( 'hash1' => { 'key1' => '1-111', 'key2' => '1-222', 'key3' => '1-333' }, 'hash2' => { 'key1' => '2-111', 'key2' => '2-222', 'key3' => '2-333' } ); How to compare…
Dcoder
  • 379
  • 2
  • 7
  • 13
0
votes
2 answers

Merge values of 2 hashes into 1 using Ruby

I have 2 hashes of hashes that I need to combine on values using Ruby hoh = Hash.new hoh = {"bob::params::search_vol_grp"=>{2=>{"search_group_id"=>2, "vol_ids"=>"2,627,628", "num_shards"=>32, "num_replicas"=>1}, 3=>{"search_group_id"=>3,…
0
votes
1 answer

Accessing hash of hashes defined in another file in perl and printing it

Now my file1 contains the hash of hashes as shown below: package file1; our %hash = ( 'articles' => { 'vim' => '20 awesome articles posted', 'awk' => '9 awesome articles posted', …
Vinod R M
  • 45
  • 8
0
votes
1 answer

How to reference and dereference a hash of hashes for subroutines in Perl

Does anyone know how to dereference a hash of hashes so that I can use it in my subroutine. As you can see, I'm having trouble accessing my Hash of Hashes data structure in my subroutine. my $HoH_ref = \%HoH; # reference the hash of…
cooldood3490
  • 2,418
  • 7
  • 51
  • 66
0
votes
1 answer

How do I delete a key from a hash?

I have a hash of hashes representing a deck of cards, I am trying to figure out how I would delete a specific card from the deck. Please let me know any suggestions or methods I should be learning or reading up on to help. @deck_of_cards = { …
BC00
  • 1,589
  • 3
  • 29
  • 47