my $mask=1<<3; # Take 1 and shift it three positions left # The parens below are NECESSARY due to binding if (($result & $mask) == $mask) { my $new_mask=1<<1; $ Move 1 to the second position $result |= $new_mask; }