# $val is up to 16 hex digits. $val = '0' . $val while length($val) < 16; my $int64= reverse pack ("H16", $val);