http://qs1969.pair.com?node_id=976891

puterboy has asked for the wisdom of the Perl Monks concerning the following question:

I have a bitstream containging 3 length fields and the corresponding 3 fields

The bitstream is layed out as follows:

<length field 1 in bits (1 byte)> <field 1> <length field 2 in bits (1 byte)> <field 2> <length field 3 in bits (1 byte)> <field 3>

I am hoping that there is some clever way to do this with unpack but I don't know how to get the field length while also unpacking without iteratively calling pack.