in reply to problem in looping
If you want to compare those files line-by-line, you should lose the second while, i.e.
while (my $line2 = <FILE2>) {
should just be
my $line2 = <FILE2>;
and, of course, remove the closing brace from the second while block.
With your code as it is now, you're comparing: 34 with 28 (diff > 2); then 34 with 97 (diff > 2); then 98 with nothing! - you've read all of 2.txt by this point.
I'd also recommend you take a look at the syntax shown in the first two example statements in the documentation for open.
-- Ken
|
|---|