in reply to Re: How much was unpack()ed?
in thread How much was unpack()ed?

If the fields are prefixed with length bytes, then you can prevent 'a*' (or 'A*' or 'Z*') from consuming the rest of the string by telling format that the length byte is there.

$x = pack 'c/a*N', '12345123451234512345', 99999; print for unpack 'c/a* N', $x; 12345123451234512345 99999

The downside is that the length byte is then consumed. To workaround that, you have to unpack the length byte twice.

print for unpack 'cXc/a* N', $x; 20 12345123451234512345 99999

However, I don't see how this helps the OP as his data has a 'type' byte but no 'length' byte.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail