in reply to Incrementing only the masked bits

Here's an incrementing solution, inspired by tye's (but not simply doing the decrement and then subtracting from $mask, which would also work).
my ($val, $mask) = (-1, 0x01000007); do { $val += ~$mask+1; $val &= $mask; printf "0x%08.8x\n", $val; } while ($val < $mask);

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: Incrementing only the masked bits (chicken eggs)
by tye (Sage) on Nov 10, 2005 at 20:18 UTC

    My version actually started out in my head closer to:

    my $mask= 0x0f000007; my $val= 0; do { printf "0x%08.8x\n", $val & $mask; $val |= ~$mask; ++$val; } while( $val <= ~0 );

    but in typing it I decided to simplify. (:

    - tye