You have odd number of chars in 987456123
and H*
packing requires even, so it assumes zero for the last pair (98
, 74
, 56
, 12
, and 30
at the end).
From perldoc:
Starting from the beginning of the template to pack(), each pair of characters is converted to 1 character of output. [...] If the length of the input string is not even, it behaves as if padded by a null character at the end. Similarly, "extra" nybbles are ignored during unpacking.