why even bother with pack()? Pass around something(... a hunk of memory) that is X x Y ints big
That is exactly what he is doing! He's also choosen to initialise it to zeros.
He could also have done that without using pack, say my $buf = chr(0) x ( $x_dimension * $y_dimension * 4 ), but that would then fail if the code is ever ported to a system where the C compiler ints are 64-bit. The way he has choesen to perform the initialisation makes it quite clear what memory represents. A good choice I think.
I am also challenging the need for 'C' in the first place.
You must have a crystal ball then, because I do not see enough information in the OP to give me the confidence to raise such a challenge.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.