in reply to Test binary equality?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Test binary equality?
by exodist (Monk) on Jun 21, 2007 at 03:11 UTC | |
I know that they are not equal though, here are the first 1024 bytes:
| [reply] [d/l] [select] |
by ysth (Canon) on Jun 21, 2007 at 03:15 UTC | |
!(... eq ...) is usually written ... ne ... | [reply] |
by exodist (Monk) on Jun 21, 2007 at 03:18 UTC | |
| [reply] |
by graff (Chancellor) on Jun 21, 2007 at 03:30 UTC | |
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. | [reply] [d/l] [select] |
by exodist (Monk) on Jun 21, 2007 at 03:50 UTC | |
The bug was that my first 2 seeks were to the same position. I seek to the end of the file because I do not know how big the file will be, I am dealing with block devices, not real files. All I know is the first 2 and last 2 512 bytes are supposed to be identical. I know that there are 2 seeks in there that are not important since they seek to where it should be anyway, but I am not necessarily keeping the code as is and may put other stuff in between them, so I put the seeks in for now so I do not forget later. | [reply] |