in reply to Re^2: Bit string manipulation made easy with Bit::Manip
in thread Bit string manipulation made easy with Bit::Manip

Mentioned bug is fixed in Bit::Manip v1.01 and Bit::Manip::PP v1.00. Essentially, I had to add an additional param to bit_set():

... my $lsb = 2; my $num_bits_to_change = 3; my $value = 0b001; $data = bit_set($data, $lsb, $num_bits_to_change, $value); ...

What was happening is that the leading zeroes in $value (0b001)) were not being counted as the length of the number of bytes to modify. The code strips all leading zeroes, so the number of bits would turn out to be one, whereby we need to change three bits. The first two (MSBs) get updated to be 0, and the last (the LSB specified) goes to 1.

_