in reply to Re: Re: Unpack()ing a stream
in thread Unpack()ing a stream
When given to pack() it consumes a list of strings and returns a single string where every string is now prefixed with the length, encoded in a big-endian 32 bit value. Its fantastic for serializing a bunch of strings. Do note - I wrote the format backwards so the "N" comes before the "A*". pack will tell you this as well so you can't make the mistake and let it just get away from you.
pack '(N/a*)*', list of strings; $foo = pack '(N/a*)*', "A", "BB", "CCC", "DDDD"; $foo eq ( "\0\0\0\1A" . "\0\0\0\2BB" . "\0\0\0\3CCC" . "\0\0\0\4DDDD" +);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Unpack()ing a stream
by BrowserUk (Patriarch) on May 24, 2004 at 19:58 UTC |