I have 2 files that are different, but compare() is telling me they're the same.

Believe me when I say I really trust you, but I think it would be a lot more satisfying for all concerned if you could post some sample data, a code snippet, and the results of an actual run of that code on that data to demonstrate the problem.

I looked at the source code for File::Compare (you can do that too), and it seems both cleverly done and reasonably solid. So I'm inclined to say you need to prove your assertion that it says two files are the same even when they are not. For example, I proved (to a small degree) that the module works as advertised, with this sequence of five shell commands:

$ echo blah > /tmp/j1 $ echo blah > /tmp/j2 $ perl -MFile::Compare -le '$r=compare("/tmp/j1","/tmp/j2"); print $r' 0 $ echo blag > /tmp/j2 $ perl -MFile::Compare -le '$r=compare("/tmp/j1","/tmp/j2"); print $r' 1
The return value "0" means the files are the same (which was true in the first run) and "1" means they are different (which was true in the second run). Can you provide a counter-example?

UPDATE: In case the problem only appears with some pair of really big files, you could also try pointing out the sizes and MD5 signatures of the two files (see Digest::MD5, or just use the gnu "md5sum" tool). Obviously, files of different sizes cannot be the same (and File::Compare checks that first), and two files of the same size but with different checksums also cannot be the same.

Identical size and checksum is not a guarantee of identical content, but at least you only have to do a full content comparison on file pairs that match on those two factors (and computing/comparing checksums is cheaper than doing comparisons of all file data).


In reply to Re: File::Compare::compare() problem by graff
in thread File::Compare::compare() problem by cascadekee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.