I ran following code
$a=pack("H1H3", "1","abc");
$b=unpack("B*", $a);
print "Got $b \n";
C:\Users\a0875499\Documents>perl abc.pl
Got 000100001010101111000000
The 'H'
format for pack()
assembles bytes, so if you supply an odd number of values it will pad out the last byte with a null nybble.
If I correctly understand what you want to achieve, you could do it with:
$a = pack("H4", "1abc");
or
$a = pack("H*", "1abc");