# convert a string of 1s and 0s to a packed network byte
sub dec2bin_vec {
      (
        $dec_val
       ,$num_bits
       ) = @_;
local (
       $str
       ,$r_str
       );
$str = unpack("B32", pack("N", $dec_val));
# otherwise you'll get leading zeros
($r_str) = $str =~ /([01]{$num_bits})$/;
return $r_str;
}
1;
