file1: 1 2 3 file2: 55 1 65 2 76 3 #### open (file, ") { @array=$_; } open (file2, "out"); while () { @array2=$_; ($one, $two) = split (/\s+/, $_); } foreach $file2 (@array2) { foreach $file1 (@array) { ###lost here