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.
In reply to Re: Problem on substr record on binary file
by moritz
in thread Problem on substr record on binary file
by bh_perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |