print unpack 'H*', $uuid;;
767adecd8ed2e11191f4b1907aa0b7e4
print unpack 'a4', $uuid;;
vzÌ═
print unpack 'C4', $uuid;;
118 122 222 205
Look up what the 'C' template does. (Hint: see also ord ).
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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".
| [reply] [Watch: Dir/Any] [d/l] |
The first snippet is clear. So is the second, which I verified, extracts the first 4 bytes into a single variable. I do not understand your output in this case 'vzI..'
Your example now makes the C template clear - it works differently in the sense that the number that follows the C is the number of octets to extract rather than number of octets to combine into a single variable.
I missed this in the docs, if it is mentioned there. Is this behaviour unique to C? Again I could not find it in the docs. If you used the docs to figure this out, I would appreciate a pointer to the section
| [reply] [Watch: Dir/Any] |
I do not understand your output in this case 'vzI..'
The last of the 4 characters, the ═ bit, is just a side effect of pasting console output into PMs code block.
Somewhere along the line, some characters with the high-bit set (ie. chars greater than 127) get converted into unicode html escape sequences.
Outside of a code block that looks like this: ═, which is exactly how it appeared on my console prior to C&P.
Is this behaviour unique to C?
No, it also applies to 'c' & 'W'.
As for documentation: for unpack, all it basically says is that it is the reverse of pack. Look at the docs for the latter, and think about the logical reverse.
But more than any other piece of Perl, the *only* way to understand pack & unpack, is to get yourself a REPL and sit and play.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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".
| [reply] [Watch: Dir/Any] [d/l] |