Data::Hash::Flatten - isomorphic denormalization of nested HoH into AoH
use Data::Hash::Flatten; my $a = { bill => { '5/27/96' => { 'a.dat' => 1, 'b.txt' => 2, 'c.lsp' => 3 } }, jimm => { '6/22/98' => { 'x.prl' => 9, 'y.pyt' => 8, 'z.tcl' => 7 } } } ; my @a = Data::Hash::Flatten->this($a, [qw(name date file)]); use Data::Dumper; print Dumper(\@a); $VAR1 = [ { 'hits' => 7, 'date' => '6/22/98', 'name' => 'jimm', 'file' => 'z.tcl' }, { 'hits' => 8, 'date' => '6/22/98', 'name' => 'jimm', 'file' => 'y.pyt' }, { 'hits' => 9, 'date' => '6/22/98', 'name' => 'jimm', 'file' => 'x.prl' }, { 'hits' => 3, 'date' => '5/27/96', 'name' => 'bill', 'file' => 'c.lsp' }, { 'hits' => 2, 'date' => '5/27/96', 'name' => 'bill', 'file' => 'b.txt' }, { 'hits' => 1, 'date' => '5/27/96', 'name' => 'bill', 'file' => 'a.dat' } ];
Oftentimes, for searchability, one needs to denormalize a HoH (hash of hash of hash of ...) into an AoH (array of hash). The answer by George_Sherston in this node gives an perfect example of how and why:
George_Sherston
http://perlmonks.org/index.pl?node_id=177346
Hence this module.
None by default.
T. M. Brannon, <tbone@cpan.org>
"Data Munging with Perl" by Dave Cross
To install Data::Hash::Flatten, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Hash::Flatten
CPAN shell
perl -MCPAN -e shell install Data::Hash::Flatten
For more information on module installation, please visit the detailed CPAN module installation guide.