Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
struct data{
char id2;
int secs;
int version;
char misc10;
char data9999;
};
How do you convert this to Perl? I'm pretty sure it has something to do with the pack() command, but I'm not exactly sure how. The problems I am having are:
a. let's say secs=65. I need it to output 0x0041 or \#0065 as opposed to print out "65" ascii. In other words I need it to be binary and fill up 2 bytes.
b. how do you load and establish a 10,000 byte array, or create a 10,000 byte array filled with binary 0's as opposed to ascii 0's to write input and output.
I know about the chr(), ord() commands, but is there an easy way to just establish or read this type of structure?
thanks in advance.
-Greg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Converting a C structure to Perl
by Fastolfe (Vicar) on Jan 05, 2001 at 12:10 UTC | |
|
Re: Converting a C structure to Perl
by repson (Chaplain) on Jan 05, 2001 at 12:02 UTC | |
|
Re: Converting a C structure to Perl
by Caillte (Friar) on Jan 05, 2001 at 15:15 UTC | |
by Fastolfe (Vicar) on Jan 05, 2001 at 19:29 UTC |