voltas has asked for the wisdom of the Perl Monks concerning the following question:
I want to print my output like Hash of Hash of Arrays, i.e. take Development as my first hash with the JIRA ID as the values and JIRA ID as the 2nd hash and the associated values. Example :=> [ 'Testing { ', 'JIRA' => 'COM-6789 ', 'Program' => 'Testing ', 'rev' => 'r876391 ', 'Reviewer' => 'Balise Mat ' 'Description' => 'Audited }, { ', 'Program' => 'Testing ', 'rev' => 'r698392 ', 'Reviewer' => 'Chan Joe ', 'JIRA' => 'COM-6789 ' 'Description' => 'SO hwat }, { ', 'JIRA' => 'COM-6789 ', 'Reviewer' => 'Chan Joe ', 'Program' => 'Testing ', 'rev' => 'r327896 ' 'Description' => 'Paid the Due } ], ' => [ 'Development { ', 'JIRA' => 'COM-1234 ', 'Reviewer' => 'John Wick ', 'rev' => 'r345676 ', 'Program' => 'Development ' 'Description' => 'Genral fix }, { ', 'Program' => 'Development ', 'rev' => 'r909276 ', 'Reviewer' => 'None ', 'JIRA' => 'COM-1234 ' 'Description' => 'Updating Received } ],
Code snippet:'Development { COM-1234 { ', 'JIRA' => 'COM-1234 ', 'Reviewer' => 'John Wick ', 'rev' => 'r345676 ', 'Program' => 'Development ' 'Description' => 'Genral fix }, { ', 'Program' => 'Development ', 'rev' => 'r909276 ', 'Reviewer' => 'None ', 'JIRA' => 'COM-1234 ' 'Description' => 'Updating Received } }, ],
#!/usr/bin/perl use strict; use warnings; use 5.010; use Data::Dumper; my @records = do { local $/ = '------------------------------------------'; <>; }; chomp @records; my %jira; foreach (@records) { next unless /\S/; my %rec = /^(\w+):\s*(.+?)$/mg; push @{$jira{$rec{JIRA}}}, \%rec; } say Dumper \%jira; my %prog foreach (@records) { next unless /\S/; my %rec = /^(\w+):\s*(.+?)$/mg; push @{$jira{$rec{Program}}}, \%rec; } say Dumper \%prog;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash of Hash of Arrays
by duyet (Friar) on Aug 24, 2016 at 16:07 UTC | |
by voltas (Novice) on Aug 25, 2016 at 10:06 UTC | |
by duyet (Friar) on Aug 26, 2016 at 10:37 UTC | |
by voltas (Novice) on Aug 26, 2016 at 14:54 UTC | |
by duyet (Friar) on Aug 27, 2016 at 05:22 UTC | |
| |
|
Re: Hash of Hash of Arrays
by GotToBTru (Prior) on Aug 24, 2016 at 12:40 UTC | |
by voltas (Novice) on Aug 24, 2016 at 13:30 UTC | |
by voltas (Novice) on Aug 25, 2016 at 10:12 UTC | |
|
Re: Hash of Hash of Arrays
by neilwatson (Priest) on Aug 24, 2016 at 12:58 UTC | |
by voltas (Novice) on Aug 24, 2016 at 13:31 UTC |