in reply to Incrementing only the masked bits

my $mask= 0x0f000007; my $val= $mask; do { printf "0x%08.8x\n", $val; --$val; $val &= $mask; } while( $val != $mask );

- tye        

Replies are listed 'Best First'.
Re^2: Incrementing only the masked bits (sure)
by GrandFather (Saint) on Nov 10, 2005 at 19:48 UTC

    Use:

    printf "0x%08.8x\n", (~$val & $mask);

    to count up.


    Perl is Huffman encoded by design.
Thanks!
by lyeoh (Acolyte) on Nov 10, 2005 at 07:44 UTC
    Thanks, I didn't think of decrementing :).

    Definitely does what I need, though it's not what I asked for. hehe.

    p.s. Sorry about the pre thing.