in reply to Re^2: increment a hex number
in thread increment a hex number

Instead of using "+1" (or "++") for the "increment", you would use "+ 0x10000".

That still involves treating the values as numbers rather than as strings:

$_ = "0x030000\n"; s/0x([\da-f]+)/sprintf("%#.*x", length($1), hex($1) + 0x10000)/ei; print;
That snippet will print "0x040000".

Replies are listed 'Best First'.
Re^4: increment a hex number
by Anonymous Monk on May 10, 2010 at 23:00 UTC
    thats dude....that will work!

    The code I do isn't much. I have a hex # converted to binary then using base64 math, I did some division built a key=>value such as 0x010000 => 65536 and thought this way seems silly and what if I miss a hex number. say my array only has 0x010000 to 0x050000....