It is unfortunate that Perl does not have native 64-bit
support (i.e. "long long"), as many compilers are adding
this.
That being said, what you are doing is functional, but
since the
Math::BigInt library does not appear to be
optimized that well, it will be slow. This may be because
the library is intended to work on
very big numbers,
much larger than 64 bit.
If speed were an issue, a quick bit of
Inline::C would
certainly help.