my $bits = pack('I>5I>1I>10I>8',$a, $b, $c, $d); my @bytes = unpack('B1 B1 B1 B1', $bits);