in reply to Detecting ineger overflow
You should be able to work out if you are going to get an overflow by comparing the result with the largest possible integer value for your system. Then you can fall through to using BigInt's.
You would be clearer by using Math::BigInt thoughout for all integer values. This allows you to use integers of arbitary size (given certain memory requirements, of course). Math::BigInt . It allows you to overload all mathematical operators when integers are declared using the format below:
use Math::BigInt; $i = new Math::BigInt '123 456 789 123 456 789';