#!/usr/bin/perl use strict; use warnings; use Math::BigInt; $_ = "DEADBEEFBABEFACE1234567890"; my $num = Math::BigInt -> new (0); # Convert the number to a Math::Int decimal number. while (length) { my $chunk = substr $_, 0, 4, ""; $num *= 2 ** (4 * length $chunk); $num += hex $chunk; } # Multiply by 2, add 1. $num *= 2; $num += 1; # Convert the Math::BigInt number to hex. my @a; while ($num) { push @a => sprintf "%X" => $num % 16; $num /= 16; } my $new = join "" => @a; print $new, "\n"; #### #!/usr/bin/perl use strict; use warnings; use Inline 'BC'; print x("DEADBEEFBABEFACE1234567890"); __DATA__ __BC__ ibase = 16 obase = 10 define x (a) { return (a * 2 + 1) }