in reply to Re^4: Hashes of Hash in perl
in thread Perl Hash

What about my proposal below?

Replies are listed 'Best First'.
Re^6: Hashes of Hash in perl
by Rajsai2825 (Novice) on Apr 17, 2013 at 14:48 UTC
    The Input Data:...............
    Summary Detailed_Summary EMC_CHECK cycleai00 chanlder 2 +08.592 1 Summary Detailed_Summary EMC_CHECK cycleai00 chanlder 3 +74.863 1 Summary Detailed_Summary EMC_CHECK cakiyaa00 chjkslyh 1. +821 1 Summary Detailed_Summary EMC_CHECK cakiyaa00 chjkslyh 8. +094 1 Summary Detailed_Summary EMC_CHECK chjkiya00 hkjkssas +6.623 1 Summary Detailed_Summary Lekatic chandana-s1 sraidnama 409.982 1 Summary Detailed_Summary Lekatic chandana-s1 sraidnama 304.887 1 Summary Detailed_Summary Lekatic chandana-s2 sraidnama 633.845 1 Summary Detailed_Summary Lekatic chandana-s2 sraidnama 340.582 1 Summary Detailed_Summary Lekatic chandana-s3 sraidnama 13.074 1 <code> The Output I am getting now after incorporating your proposal:........ +. <code> Summary Detailed_Summary EMC_CHECK cycleai00 AZ-Chandler 208.592 + 1 208.592 1 EMC_CHECK cycleai00 AZ-Chandler 208.592 + 1 TOTAL 1 208.592 EMC_CHECK cycleai00 AZ-Chandler 374.863 + 1 374.863 1 EMC_CHECK cycleai00 AZ-Chandler 374.863 + 1 TOTAL 1 374.863 EMC_CHECK cakiyaa00 NC-Charlotte 1.821 + 1 1.821 1 EMC_CHECK cakiyaa00 NC-Charlotte 1.821 + 1 TOTAL 1 1.821 EMC_CHECK cakiyaa00 NC-Charlotte 8.094 + 1 8.094 1 EMC_CHECK cakiyaa00 NC-Charlotte 8.094 + 1 TOTAL 1 8.094 EMC_CHECK chjkiya00 NY-NewYork 6.623 + 1 6.623 1 EMC_CHECK chjkiya00 NY-NewYork 6.623 + 1 TOTAL 1 6.623 Lekatic chandana-s1 PA-Levittown 304.887 1 304. +887 1 Lekatic chandana-s1 PA-Levittown 304.887 1 + TOTAL 1 304.887 Lekatic chandana-s2 PA-Levittown 409.982 1 409. +982 1 Lekatic chandana-s2 PA-Levittown 409.982 1 + TOTAL 1 409.982 Lekatic chandana-s2 PA-Levittown 340.582 1 340. +582 1 Lekatic chandana-s2 PA-Levittown 340.582 1 + TOTAL 1 340.582 Lekatic chandana-s2 PA-Levittown 633.845 1 633. +845 1 Lekatic chandana-s2 PA-Levittown 633.845 1 + TOTAL 1 633.845 Lekatic chandana-s3 PA-Levittown 13.074 1 13.0 +74 1 Lekatic chandana-s3 PA-Levittown 13.074 1 + TOTAL 1 13.074
    The Output what i want to achive:.............
    Summary Detailed_Summary Lekatic chandana-s2 sraidnama 2 974.427 Lekatic chandana-s1 sraidnama 2 714.869 Lekatic chandana-s3 sraidnama 1 13.074 Lekatic TOTAL 5 1702.37 EMC_CHECK cycleai00 chanlder 1 6.623 EMC_CHECK cakiyaa00 chjkslyh 2 583.455 EMC_CHECK chjkiya00 hkjkssas 2 9.915 EMC_CHECK TOTAL 5 599.993 Detailed_Summary TOTAL 10 2302.363 Summary TOTAL 10 2302.363 Grand TOTAL 20 5684.684
Re^6: Hashes of Hash in perl
by Rajsai2825 (Novice) on Apr 17, 2013 at 14:53 UTC
    My code:
    while (chomp(@field = split (/\t/, <RPTFILE>))) { my $fulllookupKey = $field[1]."\t". $field[2]."\t". $field[3]."\t +".$field[4]."\t".$field[5]; my $RescatKey = $field[0]; my $RessubcatKey = $field[1]; my $MasterSrkey = $field[2]; if (exists($output{$RescatKey}{$RessubcatKey}{$fulllookupKey})) + { $output{$RescatKey}{$RessubcatKey}{$fulllookupKey}->[0] += $fie +ld[6]; $output{$RescatKey}{$RessubcatKey}{$fulllookupKey}->[1] += $fie +ld[7]; } else { $output{$RescatKey}{$RessubcatKey}{$fulllookupKey}->[0] = $fiel +d[6]; $output{$RescatKey}{$RessubcatKey}{$fulllookupKey}->[1] = $fiel +d[7]; } } for my $k1 (sort keys %output){ print "$k1\n"; for my $k2 ( sort keys %{ $output{$k1} } ) { print "\t$k2\n"; for my $k3 ( sort keys %{ $output{$k1}{$k2} } ) { my $Source = substr($k3,16,100); print "\t\t$Source $output{$k1}{$k2}{$k3}->[0]\t$output{$k1}{$k2} +{$k3}->[1]\n"; print "\t\t$Source\t TOTAL \t$output{$k1}{$k2}{$k3}->[1]\t$output +{$k1}{$k2}{$k3}->[0]\n"; } } }