in reply to file comparison

Comparing digests of the data is one way to do this i.e.
use strict; use warnings; use Digest::SHA; open my $in_1, '/tmp/f1.txt'; open my $in_2, '/tmp/f2.txt'; my $hash1 = Digest::SHA::sha1_hex( do { local $/; <$in_1> } ); my $hash2 = Digest::SHA::sha1_hex( do { local $/; <$in_2> } ); die "The files are NOT the same\n" unless $hash1 eq $hash2; print "The file contents are identical\n";
If your files are really large i.e. in the order of a few gigabytes you could use md5sum on the command line to compare the files instead :
md5sum file1 file2 file3 etc
Identical files will yield identical hashes. This is useful because you do not have to load the entire file into memory first.