#Read a file that has the dates and IDs I need...each line of the file looks like...11062000C12345678 open(DATA1, "<", "dates.txt") or die $!; while () { my $dateindex = substr $_, 0, 8; my $candID = substr $_, 8, 9; #Now that I have the first date/ID I will now start to aggregate the money by Zip Code...this requires opening a second file which is formatted like this...ZIP/MONEY/DATE/ID open(DATA2, "<", "indv2000.txt") or die $!; my %hash; while () { my $zip = substr $_, 82, 5; my $money = substr $_, 130, 7; my $date = substr $_, 122, 8; my $cand1 = substr $_, 0, 9; #IF the date and candidate ID is equal to the one fed by the first while loop...then aggregate the money by zip code if ($date == $dateindex && $cand1 eq $candID){ $hash{$zip} += $money; } } #NOW that I have the total money for zip code for the day and candidate ID in question....I will print the hash separated by commas with an indication of the date/candidate ID used....I will use the dos command > to dump the output into a text file while ( ($k,$v) = each %hash ) { print "ZIP, MONEY, DATE, CANDID \n"; print "$k,$v, $dateindex, $candID, HASH \n"; } #repeat until the dates file is done... }