Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

20.
• vec(): treat a scalar as an arbitrary
length bit vector
• (you’re not using numbers, are you?)
• pack and unpack ‘b’ template is
perfect for working with the vector as
a whole
• convert vectors to and from from
strings “011100” or lists (0,1,1,1,0,0)
• count bits with unpack checksum
• perldoc -f vec
19

26.
use bytes
• binary data + DWIM + unicode
• ouch!
• pragma to the rescue: “No matter
what you think might be in this PV, do
not cleverly switch to character
semantics when I’m not looking.”
• pack/unpack themselves don’t care,
it’s things like length and substr
25

32.
• bytes, bytes, bytes on the brain
• byte offsets a natural way of thinking
about working with data
• “language neutral” is just a cute way
of saying “C”
31

33.
• “strong typing” the roundabout way
• unpack() == C cast: “I, programmer,
assure you, language, that these bytes
contain precisely data of this type,
and I will live with the consequences if
I’m wrong.”
32