Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: How do unpack templates work

by unlinker (Monk)
on Jul 20, 2012 at 20:12 UTC ( [id://982896]=note: print w/replies, xml ) Need Help??


in reply to Re^3: How do unpack templates work
in thread How do unpack templates work

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

Replies are listed 'Best First'.
Re^5: How do unpack templates work
by BrowserUk (Patriarch) on Jul 20, 2012 at 20:35 UTC
    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".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      Got it. Thank you for your patience and your time.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://982896]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-03-28 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found