I am only a Perl beginner myself (there is probably much better ways to
do this) but I put this together, I did not use the $ARGV array but that
should be easy to change, I also manually deleted blank lines and spaces
from the input files so you might want to check for those when you are
looping through your arrays:

open(Master, "master.txt") || die ("Could not open file $!");
open(DATA, "data.txt" ) || die ("Could not open file $!");


my (@temp,%master);

my @master_file = <Master>;
my @data_file = <DATA>;

close(Master);
close (DATA);

 
foreach (@master_file) {
        chomp($_);
        @temp = split(',', $_);
        $master{$temp[0]} = $temp[1];
}


foreach (@data_file) {
        chomp($_);
        @temp = split(',', $_);
        $master{$temp[0]} -= $temp[1];
}




open(NewMasterList,">>Results.txt") || die ("Could not write file
$!");
foreach (keys %master) {
        print NewMasterList "$_,$master{$_}\n";

}
 



close (NewMasterList);

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to