Help for this page

Select Code to Download


  1. or download this
    my $eight_bit_piece = 255;
    my $other_eight_bit_piece = 255;
    ...
        $other_eight_bit_piece,
        $sixteen_bit_piece);
    # Gives me 11111111 11111111 0000000000001000 as desired
    
  2. or download this
    my $piece_one_six_bits = 12;   # 001100
    my $piece_two_six_bits = 12;   # 001100
    my $piece_three_four_bits = 5; #   0101
    
    # What now?
    
  3. or download this
    my $packaged_data = pack("n",
                              $piece_one_six_bits << (6 + 4)
                            | $piece_two_six_bits << 4
                            | $piece_three_four_bits
                            );