http://www.perlmonks.org?node_id=203703


in reply to Re: Encode and decode binary-coded decimals
in thread Encode and decode binary-coded decimals


In the first case you need to use 0396 instead of 396. That's what the comment about "zero padding" refers to.
$ perl -le 'print join " ", map {ord pack "H2", $_} shift =~ /../g +' 0396 3 150

I'd expect to get: 0011 1001 011

That is at odds with my expectation.:-) Nevertheless, it isn't too difficult to change these routines to support other ascii, hex or binary representations.

--
John.