# open FILE1 and FILE2 my ($f1, $f2); while (($f1 = ) && ($f2 = ) { # split and subtract and print with $f1 and $f2 as in other suggestions. } # close all.