in reply to Difficulty restraining read function to 32 bits

while (($n = read FILE, $buffer, 4)) { $decimal = unpack("N", pack("B32", $buffer));

$buffer gets a four byte (32 bit) binary string read from the file and then you convert that with pack("B32", $buffer)???   That pack is not doing what you seem to think it is doing.   You just need the unpack:

$decimal = unpack 'N', $buffer;