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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |