in reply to Changing a bit in a string
s/([13579bdf].)$/sprintf("%02x", hex($1) - 16)/ei; [download]
Though, in practice, instead of using this obscure regexp, I would probably convert it into a bit vector and use vec to change the bit at position 31.