in reply to Need help with comparison code

Lets get the basics that a lot of people will mention out of the way up front:

Perl should then tell you about how there is no function (& vs $) called "outfile", among other things

Also my $file = @files is probably not going to do what you want. Array in scalar context gives the count of items in the array.