Within each of those 4800 bytes, there's a header (300 bytes), followed by 250 subrecords of 18 bytes each. I need to see the byte values of each of the subrecords. I thought the code would entail something like chopping off the header, recording that, and doing the same with each of the subrecords, which would in turn, get chopped up and recorded. However, I can't seem to figure out a straightforward way to do this. All the stuff I've found is for reading bytes off a filehandle, not from a string, and I know substr is pretty inefficient. Would using regexps be appropriate here? Anybody have thoughts on how to implement this?my ($filename) = shift @_; my ($ref_data) = shift @_; my ($buff, $num_records); open DATA, "<", $filename or die "Cannot open file $filename - + $!\n"; binmode(DATA); while (read(DATA, $buff, 4800)) { #print "$buff\n"; # update ref_data, recording values of data, etc } print "Processed $num_records records in file $filename\n"; close (DATA);
In reply to Reading nested records in binary data by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |