Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: forming a word from an array of its bytes

by jcb (Parson)
on Apr 08, 2021 at 23:29 UTC ( [id://11131031]=note: print w/replies, xml ) Need Help??


in reply to Re^2: forming a word from an array of its bytes
in thread forming a word from an array of its bytes

The simple way to understand that combination is that pack converts "stuff" to an octet string and unpack converts an octet string to "stuff" according to template strings. Unpacking with a different template than was used for packing reinterprets the octet string, essentially "type-punning" the data. (Type-punning is a C trick where the element of a C union object that is read is not the element that was most recently written.)

This explanation is how I remember when to use pack and when to use unpack.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-05-24 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found