At the top of this thread, you said:

All for places in the file should be exact copies of eachother, as in all 4 elements of the array should now contain the same exact binary data.

(You meant "all four places", right?) But your hexdump of the device/file indicates that the third block of 512 bytes (starting at offset 0x200) is different from the other three (starting at 0, 0x100 and 0x300).

Meanwhile, in your code snippet, I'm having trouble tracking your intent with the four "sysseek/sysread" pairs -- looks like the first two amount to reading the same block twice (?? -- was that a copy/paste error?).

And as for the third and fourth pairs, you didn't mention how big the file actually is, and in any case, seeking from the end of the file seems like an unnecessary complication (possibly a mistake).

Since the first two reads (first two elements of the array) are in fact the exact same data (from the same position in the file), your initial "if" block is never entered. (And why did you say  if (!($SB[0] eq $SB[1])) instead of the simpler  if ( $SB[0] ne $SB[1] )?)

So, what's the problem again? I don't think it's the "eq" (or "ne") comparison... I think it's a mistake in how you are reading the data from the file.


In reply to Re^3: Test binary equality? by graff
in thread Test binary equality? by exodist

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.