Before you can decide, or we can help you decide, which format specifier is the correct one to use, you will need to know how the information you are trying to unpack was packed.
For example, you mention an integer. An integer could be
- An 8-bit integer (byte),
- signed (-128 .. +127)
- unsigned (0 .. 255)
- A 16-bit integer (2 bytes/1 word)
- Signed (-32768 .. 32767 )
- Unsigned (0 .. 65535)
- A 32-bit integer (4 bytes/2 words/dword/long)
- Signed (-2147483648 .. 2147483647)
- Unsigned (0 .. 4294967295)
- A 64-bit integer (8 bytes/4 words/quadword/long long (etc!))
....
There are other formats but these are the most common.
Add to this, the possibility that some machines pack binary values into words in different (byte) orders. So called litte-endian and big-endian and with the exception of 1) above, you can double each of those possibilities, which is why pack/unpack have so many format specifiers for "integers": N n V v S s C c.
Which you need to use could be any of these, but as a guess, s, n, & v seem the most likely candidates. H seems the least likely.
In other words. You need to supply more information:)
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!
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.