If you have small files and the comparison only happens once, why not just read both into strings and test whether they are eq? If you have larger ones you should write a function that takes 2 filenames and compares the file, first checking
stat to see that the size is the same, and if they are then using
read to process the files in chunks. (For portability you can use
binmode.)
Update: Or, as an above poster suggested, use File::Compare and not write it yourself.
More generally you could use Algorithm::Diff, but it can be slow if you have largish files. Personally I would prefer to rely on diff for file comparisons, and the module only when my needs get more sophisticated...