$/ = \8; # read 8 bytes at a time; binmode INPUTFH; # don't forget this on MS-Windows! # (you can use binmode on STDIN, as well, if needed) while () { # $_ now holds 8 bytes of data ... }