document Parse::Binary::Nested features
authorMischa Poslawsky <wormy@shiar.org>
Tue, 3 Mar 2009 14:00:55 +0000 (15:00 +0100)
committerMischa Poslawsky <wormy@shiar.org>
Wed, 4 Mar 2009 14:28:20 +0000 (15:28 +0100)
Describe the differences with CORE::unpack(), since it's growing into
a superset basically.

Parse/Binary/Nested.pm

index e4cacc3b759e9eda84e26c73fad7cd80b58bf335..9bac394264d2a35709bc5fc4caa255c18ac944f0 100644 (file)
@@ -87,6 +87,38 @@ Parse::Binary::Nested - Structured unpack
 
 =head1 DESCRIPTION
 
 
 =head1 DESCRIPTION
 
+Converts a string into a hash of values, just like C<unpack>
+except that it allows you to name and nest the resulting elements.
+
+Format declarations are simalar to C<pack> templates,
+with the following additions:
+
+=over
+
+=item *
+
+An array ref groups additional declarations,
+with the first value specifying a repetition.  If this count is variable,
+the resulting value will be an array ref of hashes.
+
+       repeat => ['C', name => 'a*', value => 'S']
+
+With a count of 1, it will return only a hash ref,
+thereby simply grouping declarations:
+
+       test_foo => 'C'
+       test => [1, foo => 'C']
+
+=item *
+
+A template value of C<Ca$length> is recognised as a length-preceded string
+with a constant (maximal) size, and will return only the string adjusted
+to its length.
+This behaviour is very similar to C<(C/a@x$length)>, except that it never reads
+more than the given number of bytes.
+
+=back
+
 =head1 AUTHOR
 
 Mischa POSLAWSKY <perl@shiar.org>
 =head1 AUTHOR
 
 Mischa POSLAWSKY <perl@shiar.org>