in reply to Character in 'b' format wrapped in unpack

printf "%v02X\n", $x;
gives
AA.154.AA.154
You created characters that are too large for bytes, and `b` expects the characters to be bytes. Maybe
substr( $x, $_, 1 )) << 1
should be
( substr( $x, $_, 1 )) << 1 ) & 0xFF