Cool, thanks for sharing. I was actually looking for that solution, but just got a tooth extracted today and the brain just wasn't working right.
The 'g' modifier isn't actually necessary there, and adding 'i' lets you remove the upper case entries from the character classes. Of course, the hash lookup is as fast as you're ever going to get, but I'd still probably choose to do the functional solution.
sub incHex { s{ ( [0-9a-f] ) # Any hex digit followed by ( f* )\b # (always) trailing (optional) 'f's }{ sprintf("%x", 1 + hex $1) . '0' x length($2); }iex for @_; }
Very nice though
In reply to Re^3: Hex to decimal resulting in integer overflow (inc hex regex)
by wind
in thread Hex to decimal resulting in integer overflow
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |