Use Digest::MD5's addfile() method to determine the digests of each file and then compare the two. Alternatively, calculate a fast but less reliable System V checksum, like described in unpack:
$checksum = do {
local $/; # slurp!
unpack("%32C*",<>) % 65535;
};