in reply to compare two files on the basis of Two IDs

The if condition of this prog. is working good

Actually, it isn't. I know this because your code doesn't even compile:

$ perl -c 1172674.pl syntax error at 1172674.pl line 21, near ") or" syntax error at 1172674.pl line 26, near "else" syntax error at 1172674.pl line 30, near "}" 1172674.pl had compilation errors.

Your if statement is badly formed which is why it won't compile.