Skip to Main Content
Perl Pocket Reference, 5th Edition
book

Perl Pocket Reference, 5th Edition

by Johan Vromans
July 2011
Intermediate to advanced content levelIntermediate to advanced
104 pages
2h 14m
English
O'Reilly Media, Inc.
Content preview from Perl Pocket Reference, 5th Edition

Structure Conversion

pack template, list

Packs the values in list into a sequence of bytes, using the specified template. Returns this sequence as a string.

unpack template, expr

Unpacks the sequence of bytes in expr into a list, using template.

template is a sequence of characters as follows:

a / A

Byte string, null-/space-padded

b / B

Bit string in ascending/descending order

c / C

Signed/unsigned byte value

d / D

Native double/long double

f / F

Native float/Perl internal float

h / H

Hex string, low/high nybble first

i / I

Signed/unsigned integer value

j / J

Perl internal integer/unsigned

l / L

Signed/unsigned long value

n / N

Short/long in network (big endian) byte order

p / P

Pointer to a null-terminated/fixed-length string

q / Q

Signed/unsigned quad value

s / S

Signed/unsigned short value

u / U

Uuencoded string/Unicode UTF-8 character code

v / V

Short/long in VAX (little endian) byte order

w

A BER compressed integer

W

Unsigned character value

x / X

Null byte (skip forward)/Back up a byte

Z

Null-terminated string

. / @

Null fill or truncate to absolute/relative position

The size of an integer, as used by i and I, depends on the system architecture. Nybbles, bytes, shorts, longs, and quads are always exactly 4, 8, 16, 32, and 64 bits respectively. Characters s, S, l, and L may be followed by a ! to signify native shorts and longs instead. x and X may be followed by a ! to specify alignment.

Each character, or group of characters between parentheses, may be followed by a decimal number, optionally between [ and ], that will ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl Testing: A Developer's Notebook

Perl Testing: A Developer's Notebook

Ian Langworth, Chromatic
Perl Hacks

Perl Hacks

Chromatic, Damian Conway, Curtis Ovid Poe, Curtis (Ovid) Poe

Publisher Resources

ISBN: 9781449311186Errata Page