I would suggest two ways:
- try to use GMP and Inline::C. GMP is a multi precision library for integers and reals. (GNU Multi Precision library)
- try to use large numbers modules in Perl (but you will loose speed)
Also, it is possible that there is a GMP module for Perl.