I am trying to make a perl script that does RSA using trivially small primes (I'm specifically using the primes Bruce Schneier uses in his example in Applied Cryptography) in order to keep the problem down to a point where it fits (more or less) in the human brain. The problem is, in the code I'm doing, I'm ending up having to find ( 1019**1019 ) % 3337, and 1019**1019 blows the top off perl's default integer implementation (1019**103 pretty much gets you infinity) so getting the mod of infinity is a no-goer.
I've looked into Math::BigInt, but it has no exponentiation according to my work Perl docset. I realize that 1000**1019 is essentially 1 followed by 3069 zeroes, but I'm not seeing a clever way of handling this. I'd prefer pure perl solutions.