in reply to comparing 2 files using array

You seem to be writing a shell script with Perl. Why not drop Perl from the equation?

/me shudders at a terminal pager getting used as a Useless Use of Cat^H^H^H Less