If i understand what u want, the following works (i'll leave the printing to
another file up to you)
<snip>
use strict;
use warnings;
my %totals;
my $date;
my $count;
while (<DATA>)
{
chomp($_);
($date,$count) = split(/,/,$_);
$totals{$date} += $count;
}
while (($date,$count) = each %totals)
{
print "$date : $count\n";
}
__DATA__
07/01/02,8419
07/02/02,6344
07/03/02,6487
07/04/02,719
07/05/02,3768
07/06/02,1270
07/07/02,7
07/08/02,5179
07/09/02,9990
07/10/02,7968
07/11/02,7605
07/02/02,8892
07/03/02,5550
07/04/02,6483
07/05/02,786
07/06/02,4094
07/06/02,954
07/07/02,6
07/09/02,5232
07/10/02,10405
07/11/02,7600
07/12/02,7581
</snip>
> -----Original Message-----
> From: Deb [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 11, 2002 11:49 AM
> To: [EMAIL PROTECTED]
> Subject: summing totals by date
>
>
> Hi,
>
> I have a file in the following format, mm/dd/yy,decimal_number.
>
>
> 07/01/02,8419
> 07/02/02,6344
> 07/03/02,6487
> 07/04/02,719
> 07/05/02,3768
> 07/06/02,1270
> 07/07/02,7
> 07/08/02,5179
> 07/09/02,9990
> 07/10/02,7968
> 07/11/02,7605
> 07/02/02,8892
> 07/03/02,5550
> 07/04/02,6483
> 07/05/02,786
> 07/06/02,4094
> 07/06/02,954
> 07/07/02,6
> 07/09/02,5232
> 07/10/02,10405
> 07/11/02,7600
> 07/12/02,7581
>
> What I need to do is key on the date, then sum the numbers for the
> date, then send the date and sum to a file of the same format
> as above.
>
> So far, I've got this,
>
> $File = $ARGV[0];
> open (F, "$File") || die "Oops, did you type the right filename?\n";
>
> while (<F>) {
> ($date, $number) = split "," ;
> push (@{$numbers{$date}}, $number);
> }
>
> Does that look right? I'm not sure how to go from here. I
> really have
> a hard time understanding how to manipulate hashes. The
> syntax kills my
> brain.
>
> Any help would probably make my head quit hurting so much!
>
> deb
>
>
> --
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> =-=-=-=-=-=-=-=-=-
> There are 010 types of people in the world:
> those that understand binary, and those that don't.
> ���
> ~
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]