Well, one problem is that the first pass of your while loop for FILE2 will consume all the lines in that file and leave the file handle pointing to the end of the file (i.e eof == 1). So that on the next pass there's no more data to be read, and no lines will match.
A simple fix is to move the open FILE2 inside the loop so that you open it each time you need it.
while (<FILE1) { ... open (FILE2,'<',"name"); while(<FILE2>) { ... } close FILE2; }
It isn't very efficient to keep reopening the same file ,and there are lots of better ways but they are more complex, and we would need to know more about your problem. e.g. how big are your files?
This, Basic debugging checklist , has a number of ways you can try to understand why any code isn't doing what you expect.
Using autodie saves lots of typing for simple programs like this.
In reply to Re: Comparing FILE1 value to FILE2 range and printing matches
by RichardK
in thread Comparing FILE1 value to FILE2 range and printing matches
by edwardtickle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |