in reply to Re: Hex to decimal resulting in integer overflow
in thread Hex to decimal resulting in integer overflow
You can also do that with a single regex substitution.
BEGIN { my %n= ( 0..9, 'a'..'f', 1..9, 'a'..'f', 10 ); sub incHex { s{ ( [0-9a-fA-F] ) # Any hex digit followed by ( [fF]* )\b # (always) trailing (optional) 'f's }{ $n{ lc $1 } . '0' x length($2); }gex for @_; } }
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Hex to decimal resulting in integer overflow (inc hex regex)
by wind (Priest) on Apr 02, 2011 at 02:09 UTC | |
by tye (Sage) on Apr 02, 2011 at 02:54 UTC |