use strict; use warnings; use Bit::Manip qw(:all); my $num = 0b11100111; # or literal 231 my $bit_position = 6; my $flipped = bit_off($num, $bit_position); printf("orig: %b\n", $num); printf("flipped: %b\n", $flipped);