How about this? Still lots of open questions...
I have ignored the first 3 columns as they do not seem to make any difference (even though they have different entries, these differences are ignored in your desired output). In order to check whether columns line up properly, open in Excel with TAB delimited.
use strict;
use warnings;
my %output;
my %total;
while (my $line = <DATA>){
chomp $line;
my @field = split /\s+/, $line;
# fields 0, 1, 2 do seem to be required
$output{$field[3]}{$field[4]}{$field[5]}{COUNT} += $field[6];
$output{$field[3]}{$field[4]}{$field[5]}{VALUE} += $field[7];
$total{$field[3]}{COUNT} += $field[6];
$total{$field[3]}{VALUE} += $field[7];
$total{TOTAL}{COUNT} += $field[6];
$total{TOTAL}{VALUE} += $field[7];
}
print "Summary\n";
print "\tDetailed Summary\n";
for my $k1 (sort keys %output){
for my $k2 ( sort keys %{ $output{$k1} } ) {
for my $k3 ( sort keys %{ $output{$k1}{$k2} } ) {
print "\t\tEMC\t$k1\t$k2\t$k3\t$output{$k1}{$k
+2}{$k3}{COUNT}\t$output{$k1}{$k2}{$k3}{VALUE}\n";
}
}
print "\t\tEMC\t$k1\tTOTAL\t\t$total{$k1}{COUNT}\t$total{$k1}{
+VALUE}\n";
}
print "\tDetailed Summary\tTOTAL\t\t$total{TOTAL}{COUNT}\t$total{TOTAL
+}{VALUE}\n";
print "Summary\n";
__DATA__
Summary Detial_Summary EMC CHECK abcdefghi AZ_checker 1 20.32
Summary Detial_Summary EMC CHECK abcdefghi AZ_checker 1 24.00
Summary Detial_Summary EMC CHECK KBCDEFGHI AZ_checker 1 10.00
Summary Detial_Summary EMC CHECK KBCDEFGHI AZ_checker 1 14.00
Summary1 Detial_Summary1 EMC CHECK1 abcdefghi AZ_checker 1 20.59
Summary1 Detial_Summary1 EMC CHECK1 abcdefghi AZ_checker 1 24.00
Summary1 Detial_Summary1 EMC CHECK1 HGIJHKKIF AZ_checker 1 10.00
Summary1 Detial_Summary1 EMC CHECK1 HGIJHKKIF AZ_checker 1 14.00
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|