This seems to do what you are asking:
#!perl
use strict;
use warnings;
use Digest::MD5 qw(md5 md5_hex);
use Math::BigInt;
my $foo = 'hello, world!';
my @v = unpack('q', md5($foo));
printf "%x %x\n", @v;
my $h = substr(md5_hex($foo),0,16); # get first 8 bytes (pairs of hex
+digits)
my @w = reverse $h =~ /(..)/g; # split out the bytes and reverse
+the order
my $w = join('', @w);
my $q = Math::BigInt->from_hex($w);
print $q->as_hex();
I was surprised that it was necessary to reverse the bytes to get the same result as unpack('q', md5($foo)) but that's what it took.