in reply to Difficulty restraining read function to 32 bits

Your very attempt to limit $checksum to 32-bits is causing an overflow. & forces its arguments into native ints, and the pre-limiting value of $checksum doesn't fit into one.
$ perl -le'print $ARGV[0] & 0xFFFFFFFF' 1000000000 1000000000 $ perl -le'print $ARGV[0] & 0xFFFFFFFF' 10000000000 4294967295

Use a floating point operation.

Replace
$checksum = $checksum & 0xFFFFFFFF;
with
$checksum %= 2**32;

Replies are listed 'Best First'.
Re^2: Difficulty restraining read function to 32 bits
by TeamViterbi (Novice) on Jul 15, 2009 at 23:48 UTC
    Thanks for the quick reply ikegami. I made the replacement, but the checksum that I'm getting is just a bit shy (1 million short) of the checksum that I am trying to get (I already know the checksum). Lets say that there are 31 bits left over in the file, would the script read it and add it? or would it be 0ed out? Thanks again for your help.

      Lets say that there are 31 bits left over in the file

      Let's say 24 bits (3 bytes). It's "hard" to store a fraction number of a bytes in a file.

      read would return three bytes instead of four for the last read.

      jwkrahn points out a real problem too.