Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
unpack("a3/A A*", "007 Bond J ") gives (" Bond", "J") unpack("a3 x2 /A A*", "007: Bond, J.") gives ("Bond, J", ".")
"You write "/"sequence-item and the repeat count is obtained by popping off the last element from the stack. The sequence-item must not have a repeat count. If sequence-item refers to a string type ("A", "a", or "Z"), the length-item is the string length, not the number of strings."What does it all mean? I think when the doc talks about popping from the stack, that only applies to the numeric data. Or something. So yeah, how does that work?
Also:
"Pack and unpack can operate in two modes: character mode ("C0" mode) where the packed string is processed per character, and UTF-8 mode ("U0" mode) where the packed string is processed in its UTF-8-encoded Unicode form on a byte-by-byte basis."What's that all about? It means that with U0 pack treats the string as C-style bytearray? Or what?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pack documentation
by choroba (Cardinal) on Jun 11, 2014 at 09:18 UTC | |
|
Re: Pack documentation (unpack U0 C0 / repeat)
by Anonymous Monk on Jun 11, 2014 at 03:32 UTC | |
|
Re: Pack documentation
by LanX (Saint) on Jun 11, 2014 at 02:50 UTC | |
by Anonymous Monk on Jun 11, 2014 at 02:59 UTC |