in reply to Problem on substr record on binary file

while ($data = <DATA>) {

reads data line by line. If your binary data contains a newline somewhere (which is the case in the first line of the hexdump output, the 0x0a), the record is split up into several lines, messing up the processing of the records.

Instead you should use read to read the first two bytes, and then again read as many bytes as the second byte specifies.

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.