http://www.perlmonks.org?node_id=1170333


in reply to Hash of Hash of Arrays

Your code is incomplete, as i don't see assignment of Program Reviewer, rev, etc. Also i don't see how you can fill different JIRA and Program with same data (@records).

There is no example how your input looks like. It's difficult to figure out how it should be done.

Below is short example of how data can be processed:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Terse = 1; my $hash = {}; foreach my $line ( <DATA> ) { chomp $line; my ( $jira, $program, $rev, $reviewer, $desc ) = split /:/, $line; my $data = { JIRA => $jira, Program => $program, rev => $rev, Reviewer => $reviewer, Description => $desc, }; push @{ $hash->{ $program }}, $data; } print 'hash = ' . Dumper( $hash ); __DATA__ COM-6789:Testing:r876391:Balise Mat:Audited COM-6789:Testing:r698392:Chan Joe:SO hwat COM-6789:Testing:r327896:Chan Joe:Paid the Due COM-1234:Development:r345676:John Wick:General fix COM-1234:Development:r909276:None:Updating Received
which has the following data:
hash = { 'Development' => [ { 'Description' => 'General fix', 'JIRA' => 'COM-1234', 'Program' => 'Development', 'Reviewer' => 'John Wick', 'rev' => 'r345676' }, { 'Description' => 'Updating Received', 'JIRA' => 'COM-1234', 'Program' => 'Development', 'Reviewer' => 'None', 'rev' => 'r909276' } ], 'Testing' => [ { 'Description' => 'Audited', 'JIRA' => 'COM-6789', 'Program' => 'Testing', 'Reviewer' => 'Balise Mat', 'rev' => 'r876391' }, { 'Description' => 'SO hwat', 'JIRA' => 'COM-6789', 'Program' => 'Testing', 'Reviewer' => 'Chan Joe', 'rev' => 'r698392' }, { 'Description' => 'Paid the Due', 'JIRA' => 'COM-6789', 'Program' => 'Testing', 'Reviewer' => 'Chan Joe', 'rev' => 'r327896' } ] }