in reply to Unexpected output from while loop (was: need help with a bug)
Second, it really, really helps to state your problem clearly.
in temp.txt(output), every value of $check1 (rep. by 300)in every line is the same as the value of $check1 on the first line of file1.txt, like...doesn't tell me what you expect to have happen (well, it sort of does, but not unambiguously), and it doesn't tell me what symptoms you're seeing.
What you have set up is a loop to read F2 inside of a loop to read F1. That is, you read one record from F1, then all records from F2. If there's a second record in F1, you won't read any records from F2 unless you rewind it (seek back to the beginning of the file) first.
Another problem is that a trailing newline is retained in both $check1 and $check2, which is going to screw up the records you're printing. To get rid of them, use chomp(), as in
while ( <F1> ) { chomp; ... split ...
|
|---|