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

Another way, using fixed-length I/O (and also avoiding use of a regex to step through the string byte-by-byte):

>perl -wMstrict -le "{ local $/ = \10; my $fname = 'junk'; open my $fh, '<:raw', $fname or die qq{opening '$fname': $!}; while (defined(my $buffer = <$fh>)) { printf '%02x ', ord substr $buffer, $_, 1 for 0 .. length($buffer) - 1; print ''; } close $fh; } " 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 0d 0a

Update: BTW: The test file was created with
    perl -e "print 'a' .. 'z', qq{\n}" > junk