I have been reading the pack and unpack syntax a while now. I can figure out some simple things like basic strings, integers, etc. but I am having trouble formulating a template for the following:
I have a scalar with 512 bytes just read in from a hard drive. the bytes are as follows:
16 - Binary data (a UUID) - No idea how to put this in template
16 - Binary data (another UUID) - same
16 - string - A16?
1 byte - a number between 0 and 255 - C1
8 bytes - a 64 bit number - Q1
8 bytes - a 64 bit number - Q1
8 bytes - a 64 bit number - Q1
2 bytes - a 16 bit number - S1
so my template so far looks like this: '??A16CQQQS'
and my overall line would be: @Values = unpack('??A16CQQQS', $Buffer);
but my suspicion is that the A16 will give me 16 separate array elements, unfortunately without any idea how to do the first 2 16 byte values (which need to remain binary, completely unchanged)I cannot test it easily. as well I wonder if I can replace 'QQQ' with Q3 and get 3 separate values, one for each 64 bit number.
---below is signature, still a Work In Progress---
I would rather take 30 minutes to re-invent the wheel then take 30 days to learn how to use someone else's. Before pestering me about my re-invention prepare to defend yourself with a way of learning how to use the wheel in less time than it takes for me to make one, one that I might add is specialized to my specific task!
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.