in reply to hash or nest loop

I am sure that a lot of people can offer a better, cleaner and more efficient solution, but a couple of simple loops should do the trick.

open (FILE1, "<$file1"); @lines1 = <FILE1>; close (FILE1); open (FILE2, "<$file2"); @lines2 = <FILE1>; close (FILE1); open (FILE3, ">$file3"); foreach $line1(@lines1) { chomp $line1; ($x1,$y1,$z1) = split (/ /,$line1); foreach $line2(@lines2) { chomp $line2; ($x2,$y2,$z2) = split (/ /,$line2); print FILE3 $x1 - $x2 . "\n"; } } close (FILE3);


This code is not tested, and lacks the appropriate my,our... but it should give you a good idea of one method to tackle the problem.

Cameron