This function does the reverse of
pack
: it
takes a string (
EXPR
) representing a data structure
and expands it out into a list value, returning the list value. (In a scalar
context, it can be used to unpack a single value.) The
TEMPLATE
has much the same format as in the
pack
function - it specifies the order and
type of the values to be unpacked. (See
pack
for a more detailed description of
TEMPLATE
.)

In addition, you may prefix a field with
%
number
to
indicate that you want it to return a
number
-bit
checksum of the items
instead of the items themselves.
Default is a 16-bit checksum. For example, the following computes the
same number as the System V
sum
program:

undef $/;
$checksum = unpack ("%32C*", <>) % 32767;

The following efficiently counts the number of set bits in a bit vector: