in reply to Modifying multiple bits in a byte - bitwise operators

What I'm wondering is if there's a way to change several bits at a time. Instead of the last bit, what if I wanted to go from 10001010 to say, 10001101? (from 10 to 13 in the last four bits). Is there an easy way to do that

If you know the input is going to be (or: when it is) 10001010, that you want to change it to 10001101; simply assign the latter value to it.

Another interpretation of your requirement is that given ?????010 you want to change it to ?????101; then:

sub changeIt { my $old = shift; return ( $old & 0b11111000 ) | 0b00000101; }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice.