in reply to how to comment the lines if found a match

Since you haven't provided any code, how about some pseudocode to get you started?
OPEN file1 READ contents of file1 into array @words OPEN file2 FOR line in file 2 IF line contains any of @words PRINT "#" + line ELSE PRINT line
You might want to check out the documentation for open and perlretut.