Jun 11, 2009, 11:13 PM
Post #3 of 3
If you're attempting to convert something used by C, into something that Perl can use, then you need to learn more about Perl's, pack and unpack.
Re: [katomich] Using C structures in Perl
[In reply to]
The important part to remember is that C doesn't really care what kind of data you're dealing with. For all intent and purposes, it's just a chunk of data in memory that has an offset and an associated length (which depends on how that value is cast).
So, in the case of an array of say, 4 integers on an x86 machine. You need to know the following:
1) What endian is the data written in (for numeric values)
2) How many bytes of data are you trying to read (e.g. 16 bytes, 4 bytes at a time).
3) At what byte is each component (e.g. offset 4 byte, length 4 bytes)
Since you stated that you're not familiar with C or Perl, you have a lot of reading to do. Start with the following:
- perldoc -f pack, perldoc -f unpack
Without you being more specific, this is the best I can provide.