Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: File::Compare Binary Files

by skx (Parson)
on May 24, 2008 at 11:18 UTC ( #688273=note: print w/ replies, xml ) Need Help??


in reply to File::Compare Binary Files

This is a suggestion of another method, rather than a comment on the module you mention. When I want to compare (binary) files I do two things:

  • Use stat to get the filesize.
  • Use Digest::SHA1 to get a checksum of the file contents.

Sure collisions are possible, but for my cases I find that if the SHA1 hash and file sizes match then the files are identical enough!

Steve
--


Comment on Re: File::Compare Binary Files
Re^2: File::Compare Binary Files
by moritz (Cardinal) on May 24, 2008 at 11:33 UTC
    If you just want to compare two files (and no n-way comparisons) File::Compare can be much faster than calculating a hash because it can abort at the first difference, while the hash algorithm always has to go through both files entirely.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://688273]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2015-07-04 21:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls