$x= "0x0081def509be"; use Math::BigInt; sub bighex{ my $x = shift; return Math::BigInt->new(hex($x)) if 8 > length $x; return (bighex(substr $x,0,-4)<<16) + hex substr($x,-4); } $d = bighex($x); print "$d\n";