Here is what I ended up doing. I like CountZero solution below. That is much convenient. Cheers,
use warnings; use strict; use Time::Local; my ($ReadOp, $WriteOp); while (<DATA>) { next if ($. == 1); chomp; my @output = split/,\s?/; if ( $output[2] eq "W" ) { $WriteOp -> {$output[1]}{$output[4]} += $output[3]; } elsif ( $output[2] eq "R") { $ReadOp -> {$output[1]}{$output[4]} += $output[3]; } } print "=======\n"; print "WriteOperation\n"; print "=======\n"; for my $ip(keys %{$WriteOp}) { my $files= ${$WriteOp}{$ip}; for my $file(keys %{$files}) { print "$ip => $file => ${$WriteOp}{$ip}{$file}\n"; } } print "\n\n\n"; print "=======\n"; print "ReadOperation \n"; print "=======\n"; for my $ip(keys %{$ReadOp}) { my $files= ${$ReadOp}{$ip}; for my $file(keys %{$files}) { print "$ip => $file => ${$ReadOp}{$ip}{$file}\n"; } } __DATA__ Sun Aug 21 12:08:21 2011,172.22.32.28, W, 4964,/export/file1.log Sun Aug 21 12:08:21 2011,172.22.32.28, W, 4964,/export/file2.log Sun Aug 21 12:08:21 2011,172.22.32.28, W, 4963,/export/file2.log Sun Aug 21 12:08:21 2011,172.22.112.141, W, 9292,/export/home/another. +file Sun Aug 21 12:08:21 2011,172.22.32.28, W, 4964,/export/file2.log Sun Aug 21 12:08:21 2011,172.22.32.28, W, 2493,/export/file1.log Sun Aug 21 12:08:21 2011,172.22.32.28, W, 2355,/export/another.log Sun Aug 21 12:08:21 2011,172.22.32.28, R, 25,/export/another.log Sun Aug 21 12:08:21 2011,172.20.220.38, W, 3699,/export/file2.log Sun Aug 21 12:08:21 2011,172.20.220.146, W, 1996,<?> Sun Aug 21 12:08:21 2011,172.22.32.28, W, 2776,/export/file1.log Sun Aug 21 12:08:21 2011,172.22.32.28, R, 26,/export/file1.log

==============================

Hello gurus,

I have some raw data as following. How can I aggregate them to a report format, so that we can see total data transferred from which IP to which file. I consider using reference to parse the original data. What is the data structure I should use? Is there better way to achieve it?

Thanks in advance,

====expected report format=======

IP Write/Read TotalTransferData FileName 172.22.32.28 W 6736 /export/file1.log 172.22.220.38 W 6737 /export/file2.log

===raw data================================

# ##DATE IP Write/Read TransferData FileName # Sun Aug 21 12:08:21 2011,172.22.32.28, W, 4964,/export/file1.log Sun Aug 21 12:08:21 2011,172.22.32.28, W, 4964,/export/file2.log Sun Aug 21 12:08:21 2011,172.22.32.28, W, 4963,/export/file2.log Sun Aug 21 12:08:21 2011,172.22.112.141, W, 9292,1102,/export/home/ano +ther.file Sun Aug 21 12:08:21 2011,172.22.32.28, W, 4964,/export/file2.log Sun Aug 21 12:08:21 2011,172.22.32.28, W, 2493,/export/file1.log Sun Aug 21 12:08:21 2011,172.22.32.28, W, 2355,/export/another.log Sun Aug 21 12:08:21 2011,172.20.220.38, W, 3699,/export/file2.log Sun Aug 21 12:08:21 2011,172.20.220.146, W, 1996,<?> Sun Aug 21 12:08:21 2011,172.22.32.28, W, 2776,/export/file1.log

In reply to aggregate data by roadtest

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.