#!/usr/bin/perl
### /* This program just opens two data files 
### (which must be of the same length) and 
### calculates mean square error.*/

$file=$ARGV[0];
$file2=$ARGV[1];
print "Doing MSE on filename $file \n";
open(FILE,"$file") || die "Can't open file $file\n";
open(FILE2,"$file2") || die "Can't open file $file2\n";
while($original=<FILE>){
	$new=<FILE2>;
 	chomp($original);
	chomp($new);
	$resultant=($original-$new);
	$resultant*=$resultant;
	#print "$resultant \n";
	$final+=$resultant;
	$count++;
}
$result=$final/$count;

print "MSE: $final/$count = $result\n ";

close(FILE2);
close(FILE);
