Perhaps I am missing something. Why would it be "impossible" to have a format item "Y" (where "Y" is some unused format character, finding which may be the real problem)
such that
pack("Y4", 32); # produces "0020"
unpack("Y4", "0020"); # produces 32
There are many format characters, v among them,
that pack integers into strings and unpack strings into integers. I believe the only practical difference between "Y" and "v" is the contents of the string. The one produced by "v" may be unsuitable for display, the one produced by "Y" would be both displayable and, when displayed, indicative of the bits in the integer from which it was produced.