perl> printf "%b\n", 162;; 10100010 perl> print unpack 'b1b3b4', 162;; 1 011 0100 perl> print unpack 'B1B3B4', 162;; ## In case of different endian machines. 0 001 0011 #### perl> print unpack '(B8)4', pack 'N', 0b11111111_10101010_01010101_00000000;; 11111111 10101010 01010101 00000000 perl> print unpack '(B4)4', pack 'N', 0b11111111_10101010_01010101_00000000;; 1111 1010 0101 0000 #### perl> print unpack '(B16)2', pack 'N', 0b11111111_10101010_01010101_00000000;; 1111111110101010 0101010100000000 perl> print unpack '(B12)2', pack 'N', 0b11111111_10101010_01010101_00000000;; 111111111010 010101010000 #### perl> print unpack '(b8)3', pack 'V', 162;; 01000101 00000000 00000000 perl> print unpack 'b1 b3 b4', pack 'V', 162;; 0 000 0000 #### perl> print unpack '(B8)3', 162;; 00110001 00110110 00110010 perl> print unpack 'B1B3B4', 162;; 0 001 0011 #### perl> print unpack 'B1B3B4', '162';; 0 001 0011