If you are doing this a lot with large files, computing a cryptographic hash is the way to go. If, on the other hand you are:
1) Working on Windows
2) Working over network shares
3) Not doing too much
This little snippet I threw together the other day to compare the contents of two shares might help:
my $share = '\\\\someserver\\someshare\\"'
foreach my $file (@file_list)
{
my $file2 = $share . $file;
if (-e $file2)
{
my @cmp = `fc $file $file2 | findstr /c:"FC:"`;
if ($cmp[0])
{
unless ($cmp[0] =~ /no differences/)
{
print "$file: $cmp[0]";
}
}
else
{
print "$file:\n"
}
}
else
{
print "$file is missing from $share\n";
}
}