Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    
    ...
    
    printf "data: %s\n", $data;                # AB
    printf "bits: %s\n", join ', ', @bits;     # 1, 1, 0, 0, 1, 0, 1
    
  2. or download this
    # variant a) using floor()
    use POSIX;
    ...
    
    # variant b) using int
    $data = pack 'b*', join q{}, splice @bits, 0, int(@bits / 8) * 8;