CARVIEW |
Select Language
HTTP/2 200
server: nginx
content-type: text/plain;charset=UTF-8
content-encoding: gzip
content-security-policy: default-src 'self'; connect-src 'self' *.google-analytics.com; img-src 'self' data: www.google-analytics.com www.googletagmanager.com; script-src 'self' 'unsafe-inline' www.google-analytics.com www.googletagmanager.com; style-src 'self'; report-uri /csp-reports
accept-ranges: bytes
age: 0
date: Tue, 29 Jul 2025 03:11:08 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210036-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753758668.619712,VS0,VE866
vary: Accept-Encoding
strict-transport-security: max-age=31557600
content-length: 1164
=over
=item unpack TEMPLATE,EXPR
X
=item unpack TEMPLATE
C does the reverse of
L|/pack TEMPLATE,LIST>: it takes a string
and expands it out into a list of values.
(In scalar context, it returns merely the first value produced.)
If EXPR is omitted, unpacks the L|perlvar/$_> string.
See L for an introduction to this function.
The string is broken into chunks described by the TEMPLATE. Each chunk
is converted separately to a value. Typically, either the string is a result
of L|/pack TEMPLATE,LIST>, or the characters of the string
represent a C structure of some kind.
The TEMPLATE has the same format as in the
L|/pack TEMPLATE,LIST> function.
Here's a subroutine that does substring:
sub substr {
my ($what, $where, $howmuch) = @_;
unpack("x$where a$howmuch", $what);
}
and then there's
sub ordinal { unpack("W",$_[0]); } # same as ord()
In addition to fields allowed in L|/pack TEMPLATE,LIST>, you may
prefix a field with a % to indicate that
you want a -bit checksum of the items instead of the items
themselves. Default is a 16-bit checksum. The checksum is calculated by
summing numeric values of expanded values (for string fields the sum of
C is taken; for bit fields the sum of zeroes and ones).
For example, the following
computes the same number as the System V sum program:
my $checksum = do {
local $/; # slurp!
unpack("%32W*", readline) % 65535;
};
The following efficiently counts the number of set bits in a bit vector:
my $setbits = unpack("%32b*", $selectmask);
The C
and C
formats should be used with care. Since Perl
has no way of checking whether the value passed to
C