The C</> template character allows packing and unpacking of a sequence of
items where the packed structure contains a packed item count followed by
the packed items themselves.
-You write I<length-item>C</>I<sequence-item>.
-The I<length-item> can be any C<pack> template letter, and describes
-how the length value is packed. The ones likely to be of most use are
-integer-packing ones like C<n> (for Java strings), C<w> (for ASN.1 or
-SNMP) and C<N> (for Sun XDR).
+For C<pack> you write I<length-item>C</>I<sequence-item> and the
+I<length-item> describes how the length value is packed. The ones likely
+to be of most use are integer-packing ones like C<n> (for Java strings),
+C<w> (for ASN.1 or SNMP) and C<N> (for Sun XDR).
For C<pack>, the I<sequence-item> may have a repeat count, in which case
the minimum of that and the number of available items is used as argument
for the I<length-item>. If it has no repeat count or uses a '*', the number
-of available items is used. For C<unpack> the repeat count is always obtained
-by decoding the packed item count, and the I<sequence-item> must not have a
-repeat count.
+of available items is used.
+
+For C<unpack> an internal stack of integer arguments unpacked so far is
+used. You write C</>I<sequence-item> and the repeat count is obtained by
+popping off the last element from the stack. The I<sequence-item> must not
+have a repeat count.
If the I<sequence-item> refers to a string type (C<"A">, C<"a"> or C<"Z">),
the I<length-item> is a string length, not a number of strings. If there is
an explicit repeat count for pack, the packed string will be adjusted to that
given length.
- unpack 'W/a', "\04Gurusamy"; gives ('Guru')
- unpack 'a3/A* A*', '007 Bond J '; gives (' Bond', 'J')
- pack 'n/a* w/a','hello,','world'; gives "\000\006hello,\005world"
- pack 'a/W2', ord('a') .. ord('z'); gives '2ab'
+ unpack 'W/a', "\04Gurusamy"; gives ('Guru')
+ unpack 'a3/A A*', '007 Bond J '; gives (' Bond', 'J')
+ unpack 'a3 x2 /A A*', '007: Bond, J.'; gives ('Bond, J', '.')
+ pack 'n/a* w/a','hello,','world'; gives "\000\006hello,\005world"
+ pack 'a/W2', ord('a') .. ord('z'); gives '2ab'
The I<length-item> is not returned explicitly from C<unpack>.