in reply to Compare the content of two files

The script has a logic problem. Your loops have the effect of leaving $COMMAND1 and $COMMAND2 holding the last line in their respective files. You also have another problem, which will be evident once you add   use strict; to the top of the script.

An easy, but really ugly way to compare the two files is to change your compare to   if ( "@lines" eq "@lines1" ) { ... You can then do away with the "chomp()" loops.

Algorithm::Diff is another approach you might consider.