What do you think of this:

use strict; use warnings; my %msc_names; my %dates; my $grand_total; <DATA>; #throw away first line while (<DATA>) { chomp; my ($msc_name, $undef, $date, $count) = split /,/; #we don't use c +hunum, so we throw it away $date=~s/(\d\d)-(\d\d)-(\d\d)/$3-$2-$1/; #normalize date so it is +easier to sort $grand_total += $count; $msc_names{$msc_name}{$date} += $count; $dates{$date} += $count; } print "The grand total is: $grand_total\n\n"; print "Detailed results (by msc_name):\n"; for my $msc_name (sort keys %msc_names) { print "\t$msc_name:\n"; for my $date (sort keys %{$msc_names{$msc_name}}) { my $date2=$date; $date2=~s/(\d\d)-(\d\d)-(\d\d)/$3-$2-$1/; #reformat the date print "\t\t$date2: $msc_names{$msc_name}{$date}\n"; } } print "\nDetailed results (by date):\n"; for my $date (sort keys %dates) { my $date2=$date; $date2=~s/(\d\d)-(\d\d)-(\d\d)/$3-$2-$1/; #reformat the date print "\t$date2: $dates{$date}\n"; } __DATA__ MSC_name,chunum,date,count MSCBCR1,1,01-JUL-03,168 MSCBCR1,1,02-JUL-03,163 MSCBCR1,1,03-JUL-03,166 MSCBCR1,1,04-JUL-03,159 MSCBCR1,1,05-JUL-03,161 MSCBCR1,1,06-JUL-03,161 MSCBCR1,1,07-JUL-03,159 MSCBCR1,1,08-JUL-03,158 MSCBCR1,1,09-JUL-03,160 MSCBCR1,1,10-JUL-03,161 MSCBCR1,1,11-JUL-03,164 MSCBCR1,1,12-JUL-03,166 MSCBCR1,1,13-JUL-03,165 MSCBCR1,1,14-JUL-03,160 MSCBCR1,1,15-JUL-03,163 MSCBCR1,1,16-JUL-03,170 MSCBCR1,1,17-JUL-03,162 MSCBCR1,1,18-JUL-03,161 MSCBCR1,1,19-JUL-03,165 MSCBCR1,1,20-JUL-03,162 MSCBCR1,1,21-JUL-03,155 MSCBCR1,1,22-JUL-03,160 MSCBCR1,1,23-JUL-03,161 MSCBCR1,1,24-JUL-03,159 MSCBCR1,1,25-JUL-03,160 MSCBCR1,1,26-JUL-03,161 MSCBCR1,1,27-JUL-03,170 MSCBCR1,1,28-JUL-03,170 MSCBCR1,1,29-JUL-03,170 MSCBCR1,1,30-JUL-03,170 MSCBCR2,1,01-JUL-03,168 MSCBCR2,1,02-JUL-03,163 MSCBCR2,1,03-JUL-03,166 MSCBCR2,1,04-JUL-03,159 MSCBCR2,1,05-JUL-03,161 MSCBCR2,1,06-JUL-03,161 MSCBCR2,1,07-JUL-03,159 MSCBCR2,1,08-JUL-03,158 MSCBCR2,1,09-JUL-03,160 MSCBCR2,1,10-JUL-03,161 MSCBCR2,1,11-JUL-03,164 MSCBCR2,1,12-JUL-03,166 MSCBCR2,1,13-JUL-03,165 MSCBCR2,1,14-JUL-03,160 MSCBCR2,1,15-JUL-03,163 MSCBCR2,1,16-JUL-03,170 MSCBCR2,1,17-JUL-03,162 MSCBCR2,1,18-JUL-03,161 MSCBCR2,1,19-JUL-03,165 MSCBCR2,1,20-JUL-03,162 MSCBCR2,1,21-JUL-03,155 MSCBCR2,1,22-JUL-03,160 MSCBCR2,1,23-JUL-03,161 MSCBCR2,1,24-JUL-03,159 MSCBCR2,1,25-JUL-03,160 MSCBCR2,1,26-JUL-03,161 MSCBCR2,1,27-JUL-03,170 MSCBCR2,1,28-JUL-03,170 MSCBCR2,1,29-JUL-03,170 MSCBCR2,1,30-JUL-03,170

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law


In reply to Re: Formating Text file by CountZero
in thread Formating Text file by redskie007

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.