http://www.perlmonks.org?node_id=676783


in reply to Hex Question(s)

Prepend '0x' to the string and it will maintain its numeric value.
#!/usr/bin/perl use strict; no warnings 'numeric'; my $this = sprintf("0x%x", 40); my $that = sprintf("0x%x", 2); my $other = $this + $that; printf "$other %x\n", $other; __END__ 42 2a
Update: Added no warnings for the -w happy...

Update: This is perl, v5.6.0 built for i386-linux