To start with: After entering the loop you are reading the first line (
$line = <file1>) and throw it away (because
$line is never be used again), so from this alone we can conclude that you won't recognize a comment which starts in the first line. You would have found this immediately, if you had included
use strict; use warnings FATAL => 'all'; in your code.
There are more problems in your code, but I suggest you first enable
strict and
warnings, then try to improve the code (based on what I told you above), and if you still can't get it running, post your updated code here.
--
Ronald Fischer <ynnor@mm.st>