> I have two files say file1 and file2.
> File1 consits of records(two fields) like
Thank you for supplying sample files!
If FILE1 is not always in order:
Region1, School1
Region2, School2
Region1, School3
Then you'll need to take the print() out of that while loop and make and add
a third loop to print things out.
- Ron
---
use Inline::Files;
use strict;
my(%hash);
while ( <FILE2> ) {
chomp; next unless length;
my($school,$num_of_students_at_school) = ( split /,/ )[0,2] ;
$hash{$school} += $num_of_students_at_school;
}
while ( <FILE1> ) {
chomp; next unless length;
my($region,$school) = split /,\s?/ ;
print $region, " has [", $hash{$school}, "] students\n";
}
__FILE1__
Region1, School1
Region2, School2
Region3, School3
__FILE2__
School1,10,210
School2,1,20
School3,20,410
School1,10,300
__OUTPUT__
Region1 has [510] students
Region2 has [20] students
Region3 has [410] students
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web