
raxip
Novice
Jun 11, 2009, 11:13 PM
Post #3 of 3
(424 views)
|
|
Re: [katomich] Using C structures in Perl
[In reply to]
|
Can't Post
|
|
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. 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: - http://en.wikipedia.org/wiki/Endianness - perldoc -f pack, perldoc -f unpack - http://perl.active-venture.com/pod/perlpacktut-packing.html - http://www.google.com/#q=site%3Asearch.cpan.org+struct+c Without you being more specific, this is the best I can provide.
|