I am trying to converting a C program to Perl. One of the main stopping points with me is the fact that I have a C structure that is something like this:
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

In reply to Converting a C structure to Perl by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.