Name

pack

Synopsis

pack template, list
                  

Takes a list of values and packs it into a binary structure, returning the string containing the structure. templateis a sequence of characters that give the order and type of values, as follows:

Character

Meaning

@

Null-fill to absolute position.

(

Start of a ( ) group.

a

An ASCII string, will be null padded.

A

An ASCII string, will be space padded.

b

A bit string, low-to-high order (such as vec( )).

B

A bit string, high-to-low order.

c

A signed char value.

C

An unsigned char value.

d

A double-precision float in the native format.

D

A long double-precision float in the native format. Long doubles are avai able only if your system supports long double values and if Perl has been compiled to support these values. Causes a fatal error otherwise. New in 5.8.

f

A single-precision float in the native format.

F

A floating-point value in the native format, i.e., a Perl internal floating-point value (NV). New in 5.8.

h

A hexadecimal string, low nybble first.

H

A hexadecimal string, high nybble first.

i

A signed integer value.

I

An unsigned integer value.

l

A signed long value.

j

A signed integer value, i.e., a Perl internal integer (IV). New in 5.8.

J

An unsigned integer value, i.e., a Perl internal unsigned integer (UV). New in 5.8.

L

An unsigned long value.

n

A short in “network” (big-endian) order.

N

A long in “network” (big-endian) order.

p

A pointer to a string.

P

A pointer to a structure (fixed-length string).

q

A signed quad (64-bit) value. ...

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.