in reply to running multiple loops
It works fine for the first line in file1
The problem is that once you've read through the files 2 and 3, their file pointers will be at end of file (EOF), so further reads in subsequent iterations of the outer loop return nothing.
One solution would be to repeatedly seek to the beginning of the files. Another solution would be to read the contents of file 2 and 3 into arrays.
In Section
Seekers of Perl Wisdom