in reply to Re^2: Reading binary file byte by byte
in thread Reading binary file byte by byte

Then we are back to reading a byte at a time from a file, which needs some thought applied first in terms of performance. It might be better than sysread which forces a system call with a 1 byte buffer, if thats what you request.

Either way, if using buffered I/O, it seems more ept to read at least a page of memory in size at a time from the file but then process that one byte at a time.

One world, one people

Replies are listed 'Best First'.
Re^4: Reading binary file byte by byte
by ikegami (Patriarch) on Dec 23, 2010 at 16:03 UTC
    read and readline (<>) are buffered, so it's not that bad. If you need Perl-side buffering, the following would be much better:
    use constant BLK_SIZE => 64*1024; { open(my $FILE, "file.binary") or die $!; binmode($FILE); while (read($FILE, my $buf, BLK_SIZE)) { for my $byte (unpack('a*', $buf)) { ... } } close $FILE; }