in reply to Re: Can unpack add zero bytes before converting?
in thread Can unpack add zero bytes before converting?

Maybe unpack can't but pack can :)

try:

return unpack '(Q<)*', pack '(a8)*', unpack "(a$length)*", $stream;

And you no longer need $pad or the map.

semi-tested :)

Replies are listed 'Best First'.
Re^3: Can unpack add zero bytes before converting?
by Anonymous Monk on Sep 13, 2021 at 12:45 UTC

    See? I knew someone would come up with something cleaner. Thanks.

    I understand the OP to have requested that it be done in a single unpack, but I'm convinced that is not possible -- a challenge for someone to come along and prove me wrong. And that is how knowledge grows.