pimperator has asked for the wisdom of the Perl Monks concerning the following question:
I have this input file I want to turn into a multidimensional hash
NAME NUMBER COLOR GNAEUS 1 BLUE GNAEUS 1 RED FABIUS 1 BLUE FABIUS 2 YELLOW FABIUS 1 RED ....
This is how I am turning it into a hash of hashes
undef my %hash; open IN, $ARGV[0]; while(<IN>){ chomp $_; my ($name,$number,$color) = split /\t/, $_; $hash{$name}{$number}{$color}++; }
Here's some pseudo-code of what I'm trying to accomplish
my %returnedHash = grep / $hash{"GNAEUS"}{"1"} / keys %hash; foreach my $name (keys %returnedHash){ foreach my $number (keys %{$returnedHash{$name}}){ foreach my $color (keys %{$returnedHash{$name}{$number}}){ print $returnedHash{$name}{$number}{$color}; } } }
I'm at a loss at the moment. That's why I'm here. Please help me o'Monks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Grep hash of hashes
by choroba (Cardinal) on Dec 02, 2014 at 09:27 UTC | |
|
Re: Grep hash of hashes
by Anonymous Monk on Dec 02, 2014 at 08:06 UTC | |
|
Re: Grep hash of hashes
by McA (Priest) on Dec 02, 2014 at 08:08 UTC | |
by Anonymous Monk on Dec 02, 2014 at 09:35 UTC | |
by McA (Priest) on Dec 02, 2014 at 09:49 UTC |